Ahmed-elsayed-mahmoud commented on a change in pull request #3789: Refactoring
the load balancer with an overflow queue to reduce activation waiting time
URL:
https://github.com/apache/incubator-openwhisk/pull/3789#discussion_r197611644
##########
File path:
core/controller/src/main/scala/whisk/core/loadBalancer/ShardingContainerPoolBalancer.scala
##########
@@ -133,38 +135,91 @@ class ShardingContainerPoolBalancer(config: WhiskConfig,
controllerInstance: Ins
/** 1. Publish a message to the loadbalancer */
override def publish(action: ExecutableWhiskActionMetaData, msg:
ActivationMessage)(
implicit transid: TransactionId): Future[Future[Either[ActivationId,
WhiskActivation]]] = {
+ val hash =
ShardingContainerPoolBalancer.generateHash(msg.user.namespace.name,
action.fullyQualifiedName(false))
+ publish(msg.transid, action.limits.timeout.duration.toSeconds.toInt,
action.exec.pull, hash, msg, false)
+ }
+ def publish(
+ transid: TransactionId,
+ actionTimeoutSeconds: Int,
+ pull: Boolean,
+ hash: Int,
+ msg: ActivationMessage,
+ isRescheduled: Boolean): Future[Future[Either[ActivationId,
WhiskActivation]]] = {
+ logging.info(this, s"Publish activation ${msg.activationId} with &
isRescheduled= $isRescheduled")
val (invokersToUse, stepSizes) =
- if (!action.exec.pull) (schedulingState.managedInvokers,
schedulingState.managedStepSizes)
+ if (!pull) (schedulingState.managedInvokers,
schedulingState.managedStepSizes)
else (schedulingState.blackboxInvokers,
schedulingState.blackboxStepSizes)
+
val chosen = if (invokersToUse.nonEmpty) {
- val hash =
ShardingContainerPoolBalancer.generateHash(msg.user.namespace.name,
action.fullyQualifiedName(false))
- val homeInvoker = hash % invokersToUse.size
- val stepSize = stepSizes(hash % stepSizes.size)
- ShardingContainerPoolBalancer.schedule(invokersToUse,
schedulingState.invokerSlots, homeInvoker, stepSize)
+ // In case of the system isn't in overflow state or it's in the overflow
state but the message is rescheduled
+ // we want to call the schedule algorithm to choose an invoker
+ if (!overflowState.get() || (overflowState.get() && isRescheduled)) {
+ val homeInvoker = hash % invokersToUse.size
+ val stepSize = stepSizes(hash % stepSizes.size)
+ ShardingContainerPoolBalancer.schedule(invokersToUse,
schedulingState.invokerSlots, homeInvoker, stepSize)
+ } else {
+ // In case of the system is in overflow state and the
ActivationMessage isn't rescheduled
+ // return -1 indicates as an index for the invoker
+ Some(new InstanceId(-1))
Review comment:
Yes. We need to differentiate between three cases. First, there is no
invokers in the system and this case returns `None`. Second, there is invokers
in the system but they are busy not free to schedule and this case returns
`Some(new InstanceId(-1))` where -1 is a dummy index. Third, there is invokers
in the system and there exists one invoker that can schedule the activation and
this case returns `Some(invoker.id)`.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services