mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
outlet/kafka: decrease if we have many scale down requests
Don't wait for a majority. Just a third of them should be enough. We have a 10-factor between underloaded and overloaded.
This commit is contained in:
@@ -164,8 +164,8 @@ func runScaler(ctx context.Context, config scalerConfiguration) chan<- ScaleRequ
|
||||
}
|
||||
}
|
||||
|
||||
// Scale down if we have a majority of decrease requests.
|
||||
if decreaseCount > steadyCount {
|
||||
// Scale down if we have many decrease requests
|
||||
if decreaseCount > steadyCount/2 {
|
||||
current := config.getWorkerCount()
|
||||
target := state.nextWorkerCount(ScaleDecrease, current, config.minWorkers, config.maxWorkers)
|
||||
if target < current {
|
||||
|
||||
@@ -154,18 +154,12 @@ func TestScalerRateLimiter(t *testing.T) {
|
||||
time.Sleep(time.Second)
|
||||
ch <- ScaleDecrease
|
||||
}
|
||||
// time=7m, no change (180 vs 120)
|
||||
check([]int{8, 12, 11, 12, 13, 12, 11})
|
||||
// time=7m, decrease (180 vs 120)
|
||||
check([]int{8, 12, 11, 12, 13, 12, 11, 10})
|
||||
for range 30 {
|
||||
time.Sleep(time.Second)
|
||||
ch <- ScaleDecrease
|
||||
}
|
||||
// time=7m30s, no change (150 vs 150)
|
||||
check([]int{8, 12, 11, 12, 13, 12, 11})
|
||||
time.Sleep(time.Second)
|
||||
ch <- ScaleDecrease
|
||||
// OK, now more decrease than increase!
|
||||
check([]int{8, 12, 11, 12, 13, 12, 11, 10})
|
||||
|
||||
// We should not account for steady requests for too long!
|
||||
time.Sleep(time.Minute)
|
||||
|
||||
Reference in New Issue
Block a user