Back to all scenarios
Scenario #410
Scaling & Load
Kubernetes v1.22, Azure AKS

Application Didn’t Handle Scale-In Gracefully

App lost in-flight requests during scale-down, causing 5xx spikes.

Find this helpful?
What Happened

Pods were terminated abruptly during autoscaling down, mid-request.

Diagnosis Steps
  • 1Observed 502/504 errors in logs during scale-in events.
  • 2No termination hooks present.
Root Cause

No preStop hooks or graceful shutdown handling in the app.

Fix/Workaround
• Implemented preStop hook with delay.
• Added graceful shutdown in app logic.
Lessons Learned

Scale-in should be as graceful as scale-out.

How to Avoid
  • 1Always include termination handling in apps.
  • 2Use terminationGracePeriodSeconds wisely.