Common backend failure patterns · mid
Retry storms, cache stampedes and thundering herds
When something small fails, retries and empty caches can multiply the load until the system cannot recover. The cure is to retry at one layer with backoff and jitter, protect the database, and bring traffic back slowly.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Retries multiply across layers. The SRE book example: 3 retries at each of 3 layers gives 4 x 4 x 4 = 64 attempts for one user action.
- Death spiral: liveness probes that query the database fail under load, Kubernetes restarts pods, and the remaining pods get more load. Keep the database out of liveness checks.
- Bring a system back: shed load at the edge (rate limits, 503 with Retry-After), turn off retries in the gateway, then let traffic back in gradually. Old app versions keep retrying, so the server needs per-client rate limits and cheap load shedding.
- Retry design: one layer only, exponential backoff with full jitter, a cap on attempts, a retry budget, only for idempotent calls, and honour Retry-After.
- Cache stampede: after a restart the cache is empty, every request hits the database, queries time out, nothing is written back, and the cache never fills.
- Warm the cache at a controlled rate for the top keys. If the script gives every key the same TTL, they all expire together: add random jitter to TTLs.
- Fixes for stampedes: request coalescing (single flight, or a short lock with SET key value NX PX), stale-while-revalidate, TTL jitter, and probabilistic early refresh (XFetch).
- The SRE book point: if the service cannot survive an empty cache, it is a capacity cache, and losing it is an outage. Plan Redis with a replica and failover, and plan for cold starts.
The red pen
Common traps: mistake → fix
Mistake: More retries make a request more likely to succeed
Fix: during an overload, retries add load and delay recovery.
Mistake: A cache only makes things faster
Fix: if the database cannot survive without it, losing the cache is an outage.
Mistake: Warming the cache all at once is safe
Fix: same TTLs expire together; add jitter and control the rate.
Easy to hard
Questions interviewers ask, easy to hard
- After a database failover, requests per user went up six times. What is happening?
- How do you design retries so they help and do not hurt?
- Redis restarted and the database is at 100% CPU. What do you do now, and what is the fix?
- What is request coalescing?
- Why is it risky to put a database query in a liveness probe?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.