Skip to content

Commit

Permalink
Merge pull request #27 from practo/bug-scaling
Browse files Browse the repository at this point in the history
Scale up above 1 only when only above target
  • Loading branch information
alok87 authored Aug 26, 2019
2 parents 1e99036 + b0be513 commit ab7e4e1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,11 @@ func (c *Controller) getDesiredWorkers(
if math.Abs(1.0-usageRatio) <= tolerance {
return currentWorkers
}

if queueMessages < targetMessagesPerWorker {
return currentWorkers
}

desiredWorkers := int32(math.Ceil(usageRatio * float64(currentWorkers)))
// to prevent scaling down of workers which could be doing processing
if desiredWorkers < currentWorkers {
Expand All @@ -383,7 +388,7 @@ func (c *Controller) getDesiredWorkers(
return convertDesiredReplicasWithRules(desiredWorkers, minWorkers, maxWorkers)
}

if idleWorkers != 0 {
if idleWorkers > 0 {
desiredWorkers := currentWorkers - idleWorkers
return convertDesiredReplicasWithRules(desiredWorkers, minWorkers, maxWorkers)
}
Expand Down

0 comments on commit ab7e4e1

Please sign in to comment.