@@ -58,6 +58,7 @@ class SchedulingDecisionMaker(
58
58
inProgressContainerCountInNs,
59
59
averageDuration,
60
60
limit,
61
+ maxActionConcurrency,
61
62
stateName,
62
63
_) = snapshot
63
64
val totalContainers = existing + inProgress
@@ -137,7 +138,7 @@ class SchedulingDecisionMaker(
137
138
// but it is a kind of trade-off and we place latency on top of over-provisioning
138
139
case (Running , None ) if staleActivationNum > 0 =>
139
140
// we can safely get the value as we already checked the existence
140
- val num = staleActivationNum - inProgress
141
+ val num = ceiling( staleActivationNum.toDouble / maxActionConcurrency.toDouble) - inProgress
141
142
// if it tries to create more containers than existing messages, we just create shortage
142
143
val actualNum = if (num > availableMsg) availableMsg else num
143
144
addServersIfPossible(
@@ -153,7 +154,7 @@ class SchedulingDecisionMaker(
153
154
// need more containers and a message is already processed
154
155
case (Running , Some (duration)) =>
155
156
// we can safely get the value as we already checked the existence
156
- val containerThroughput = staleThreshold / duration
157
+ val containerThroughput = ( staleThreshold / duration) * maxActionConcurrency
157
158
val expectedTps = containerThroughput * (existing + inProgress)
158
159
val availableNonStaleActivations = availableMsg - staleActivationNum
159
160
@@ -201,7 +202,7 @@ class SchedulingDecisionMaker(
201
202
// this case is for that as a last resort.
202
203
case (Removing , Some (duration)) if staleActivationNum > 0 =>
203
204
// we can safely get the value as we already checked the existence
204
- val containerThroughput = staleThreshold / duration
205
+ val containerThroughput = ( staleThreshold / duration) * maxActionConcurrency
205
206
val num = ceiling(staleActivationNum.toDouble / containerThroughput)
206
207
// if it tries to create more containers than existing messages, we just create shortage
207
208
val actualNum = (if (num > staleActivationNum) staleActivationNum else num) - inProgress
@@ -219,7 +220,7 @@ class SchedulingDecisionMaker(
219
220
// same with the above case but no duration exist.
220
221
case (Removing , None ) if staleActivationNum > 0 =>
221
222
// we can safely get the value as we already checked the existence
222
- val num = staleActivationNum - inProgress
223
+ val num = ceiling( staleActivationNum.toDouble / maxActionConcurrency.toDouble) - inProgress
223
224
// if it tries to create more containers than existing messages, we just create shortage
224
225
val actualNum = if (num > availableMsg) availableMsg else num
225
226
addServersIfPossible(
0 commit comments