CASCADING FAILURES
One node dies, the survivors inherit its load, then they die
Three replicas sit behind a load balancer that evicts any replica failing its health check. Each can serve 100 req/s and runs at 70%. None ever refuses work: they queue everything, no shedding. One crashes. Which of these is true 60 seconds later?
Three replicas each serve 100 req/s and run at 70%. One crashes. The balancer spreads 210 req/s across the two survivors: 105 req/s each. A 5% overload does not look dangerous, but each survivor’s queue grows 5 requests every second and never shrinks. The health check waits in that same queue. After 20 s it waits more than its 1 s timeout; two misses and the balancer evicts the replica. The last one gets 210 req/s and fails within seconds. One crash becomes three.
The fix is shedding at each replica: serve 100 req/s, answer 503 at once to the rest. The queue stays short, the health check keeps passing, and the cluster serves 200 of 210 req/s instead of 0. Headroom helps too: N replicas survive one loss only if utilisation is below (N-1)/N.
// Each replica accepts whatever the balancer sends.
app.use((req, res, next) => next());
app.get('/health', (req, res) => res.send('ok')); // waits in the same queue as everything else
// One crash → survivors at 105% → queues grow → /health times out → evicted → the rest get 210%// Each replica refuses what it cannot serve in time, so it never falls over.
app.use((req, res, next) => {
if (server.pendingRequests() >= CAPACITY) return res.status(503).end(); // fast, cheap
next();
});
app.get('/health', (req, res) => res.send('ok')); // still answers: the queue stays short
// And keep headroom: N replicas at u% survive one loss only if u < (N-1)/N. Watch the invariant strip in ONE DIES, NO SHEDDING: both invariants hold for 28 seconds after the crash while the queues grow, then both go red in one step. In FIX: SHED AT EACH REPLICA the same crash happens and both stay green: 2 of 3 replicas healthy, 200 of 210 req/s served. Then raise REPLICAS to 4 and watch the cascade not happen at all.
Three replicas at 70% each, no shedding. Crash one replica and find a position where the whole cluster is down by the end of the window.
GOAL: no healthy replica is left at the end of the window
Three replicas, 100 req/s each, 210 req/s of demand. R1 crashes at t = 2 s. Rewrite routeAndServe so each replica accepts only what it can serve and the cluster never collapses. A replica whose queue is deeper than 1 s of work fails its health check; two in a row and it is evicted.
Any replicated service behind a balancer with health checks: Kubernetes readiness probes evicting overloaded pods, database connection storms after a primary failover, cache fleets where one node's loss sends its keys to the rest, retry storms that turn one slow dependency into a fleet-wide outage. The telltale shape is a staircase of unhealthy nodes, each step faster than the last.
“One of your replicas died and the rest followed. Walk me through it.” Describe the redistribution, the queue growth, the health check timing out inside that queue, and the eviction loop. Then give the three fixes: shed per replica, keep headroom below (N-1)/N, and during recovery cut load at the edge before adding capacity.
USED IN
Chapters that build on this lesson.
- On-call and incidents for managersEngineering Manager
- Technical decisions as a managerEngineering Manager
- Chaos and resilience testingSRE, Platform and DevOps
- Production readiness reviewsSRE, Platform and DevOps
- Leading a sev-1 as the technical leadStaff and Principal Engineer