NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior0 views

How did you avoid flapping during Kubernetes autoscaling in response to short-lived load spikes?

Practice

AI answer

I configured HPA to use smoothed metrics with an appropriate averaging window rather than instantaneous metric values, so that a brief spike would not trigger unnecessary scaling. I set behavior policies for changing the number of replicas and a longer stabilization window for scale-down (scaleDown.stabilizationWindowSeconds) to reduce fluctuations; for scale-up, I chose a sufficiently fast response to avoid worsening latency. I also set reasonable minReplicas and maxReplicas values.

I checked that the metric actually reflected application saturation and that readiness probes did not count pods that were still warming up as available capacity. I validated thresholds and windows with load tests. For KEDA, I configured cooldown and polling intervals in a similar way. After deployment, I monitored the number of replicas, latency, queues, and HPA events to make sure scaling was not oscillating.