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/05/07 08:45:04 UTC

[GitHub] hykych opened a new issue #3618: Why did you deprecate the LoadBalancerService and use ShardingContainerPoolBalancer?

hykych opened a new issue #3618: Why did you deprecate the LoadBalancerService and use ShardingContainerPoolBalancer?
URL: https://github.com/apache/incubator-openwhisk/issues/3618
 
 
   I understand the ShardingContainerPoolBalancer use 'horizontal' sharding to not collide with fellow loadbalancers, but according to the following code snippet, you seem to not fully use warm containers.
     
   You just return an invoker that has some slots on it, not an invoker that have some warm containers which are specialized to a particular function on it.  
   
   Do you have any plan to change this to fully use warm containers? 
   ```
   /**
      * Scans through all invokers and searches for an invoker tries to get a free slot on an invoker. If no slot can be
      * obtained, randomly picks a healthy invoker.
      *
      * @param invokers a list of available invokers to search in, including their state
      * @param dispatched semaphores for each invoker to give the slots away from
      * @param index the index to start from (initially should be the "homeInvoker"
      * @param step stable identifier of the entity to be scheduled
      * @return an invoker to schedule to or None of no invoker is available
      */
     @tailrec
     def schedule(invokers: IndexedSeq[InvokerHealth],
                  dispatched: IndexedSeq[ForcableSemaphore],
                  index: Int,
                  step: Int,
                  stepsDone: Int = 0)(implicit logging: Logging): Option[InstanceId] = {
       val numInvokers = invokers.size
   
       if (numInvokers > 0) {
         val invoker = invokers(index)
         // If the current invoker is healthy and we can get a slot
         if (invoker.status == Healthy && dispatched(invoker.id.toInt).tryAcquire()) {
           Some(invoker.id)
         } else {
           // If we've gone through all invokers
           if (stepsDone == numInvokers + 1) {
             val healthyInvokers = invokers.filter(_.status == Healthy)
             if (healthyInvokers.nonEmpty) {
               // Choose a healthy invoker randomly
               val random = healthyInvokers(ThreadLocalRandom.current().nextInt(healthyInvokers.size)).id
               dispatched(random.toInt).forceAcquire()
               logging.warn(this, s"system is overloaded. Chose invoker${random.toInt} by random assignment.")
               Some(random)
             } else {
               None
             }
           } else {
             val newIndex = (index + step) % numInvokers
             schedule(invokers, dispatched, newIndex, step, stepsDone + 1)
           }
         }
       } else {
         None
       }
     }
   ```

----------------------------------------------------------------
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