Interview Prep/Kubernetes/Resources, autoscaling and scheduling

Your HPA flaps between 5 and 20 replicas every few minutes. How do you stabilise it?

AdvancedScenarioResources, autoscaling and scheduling
Answer

Situation read → Oscillating replicas cause cold starts and cost.

What I'd do →

  1. Set behavior.scaleDown.stabilizationWindowSeconds: 300
  2. Limit rate with policies (for example 2 pods per 60s on scale down)
  3. Use a more stable metric, for example averaged requests per second
  4. Fix slow startup with startup probes so new pods count correctly
  5. Review target utilisation

Why → Stabilisation windows make the HPA use the highest recommendation in the window, so it scales down slowly.

Interview tip → Mention autoscaling/v2 behavior field.

All Kubernetes questions Roadmap: Kubernetes core

More on Resources, autoscaling and scheduling