From 9884163c20df6d800d13d4c353f4135ebb1a523f Mon Sep 17 00:00:00 2001 From: Alok Kumar Singh Date: Mon, 26 Aug 2019 16:05:41 +0530 Subject: [PATCH 1/2] Scale up above 1 only when only above target --- pkg/controller/controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index c2a328c0..64177d6c 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -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 { From b0be5137fa89bc973744e78ffa8cd9b51a52afed Mon Sep 17 00:00:00 2001 From: Alok Kumar Singh Date: Mon, 26 Aug 2019 11:35:00 +0000 Subject: [PATCH 2/2] Idle workers when not initialized is -1, so != does not hold true --- pkg/controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 64177d6c..df9d03f1 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -388,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) }