Someone flushed Redis to fix stale data; seconds later the DB hit 100% CPU and the site threw 5xx for 15 minutes.
AdvancedTroubleshooting5xx errors
Answer
Likely causes → Cache stampede (thundering herd): every request missed the cache at once and went to the DB, which was sized for a 95% hit rate.
Diagnose → Cache hit ratio dropped to near zero exactly when DB QPS and CPU spiked.
Fix → Shed load: rate-limit at the edge, temporarily serve stale or static responses, and warm the hottest keys from a script. Scale read replicas if available.
Prevent → Never FLUSHALL in production; invalidate specific keys instead. Use request coalescing (single-flight) so one request refills each key, add TTL jitter, and plan DB capacity for a cold-cache scenario.
More on 5xx errors
Right after a release, 500s spike to 8% and logs show `java.lang.NullPointerException` in a new code path.BeginnerLong-running report exports fail with "504 Gateway Time-out" from the ALB at exactly 60 seconds.Beginnernginx logs "upstream prematurely closed connection while reading response header from upstream" and users get 502.IntermediateEvery deploy causes 10–20 seconds of 502s from the ALB, even with a rolling update.IntermediateA Node.js service behind an ALB returns a steady trickle of 502s under normal load, with no app errors at all.AdvancedThrough Istio, clients get "503 upstream connect error or disconnect/reset before headers. reset reason: connection failure".Intermediate