A 12-node sharded cluster has automatic failure detection and automatic rebalancing. During a traffic peak one node slows down, is marked dead, and within ten minutes three more nodes have been marked dead too. Walk through why, and how you would redesign it.
Sketch your own answer first, then compare it with the one below.
A strong answer
The slow node is the trigger. The detector sees missed heartbeats, which a loaded machine produces, and declares it dead. Rebalancing then copies its partitions to the other nodes. That copying reads, sends and writes a lot of data on machines already at peak, so they slow down. Their heartbeats start to slip, the detector marks another one dead, more partitions move, and the loop feeds itself. It is a classic metastable failure: the recovery action is the load that sustains the outage.
The headroom is also thin. When one of 12 nodes is lost, each survivor takes 12/11 of its old load. At 85 percent utilisation that is 93 percent, before any copying.
Redesign in several places. Make the detector less eager: longer timeouts, require several missed checks, and distinguish slow from dead. Delay rebalancing after a failure. Replication already covers the data, so wait some minutes before copying, since most blips are brief. Rate-limit rebalancing traffic, and prioritise live requests over it. Cap how many nodes can be marked dead at once, and pause automation when too many are suspected, since that usually means a shared cause like the network. Keep the capacity plan honest, with enough headroom to lose a node at peak. And keep a human approval step for large moves.
Sources
- Martin Kleppmann (2017). Designing Data-Intensive Applications.
- Giuseppe DeCandia and others (2007). Dynamo: Amazon's Highly Available Key-value Store.