You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/11 09:15:57 UTC

[GitHub] markusthoemmes commented on a change in pull request #3272: improve loadbalancer's schedule algorithm

markusthoemmes commented on a change in pull request #3272: improve loadbalancer's schedule algorithm
URL: https://github.com/apache/incubator-openwhisk/pull/3272#discussion_r167427306
 
 

 ##########
 File path: core/controller/src/main/scala/whisk/core/loadBalancer/ContainerPoolBalancer.scala
 ##########
 @@ -345,7 +345,8 @@ object ContainerPoolBalancer extends LoadBalancerProvider {
         .find(_._3 < invokerBusyThreshold)
         .orElse(invokerProgression.find(_._3 < invokerBusyThreshold * 2))
         .orElse(invokerProgression.find(_._3 < invokerBusyThreshold * 3))
-        .orElse(invokerProgression.headOption)
+        .orElse(
+          if (invokerProgression.size == 0) None else invokerProgression.lift(Random.nextInt(invokerProgression.size)))
 
 Review comment:
   The extra check for `size == 0` is redundant I think, since `lift` will automatically bound-check anyway.
   
   It is **crucial** to use `ThreadLocalRandom` vs. `Random` because getting randomness is synchronized and thus will result in thread-contention.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services