Try
↑ ↓ move↵ openesc close

Interview prep / Failure detection

Senior · Failure detection · System design interview question

Design the failure detection for a cluster of a few hundred nodes. Who monitors whom, how does suspicion spread, and how do you avoid a partition splitting the cluster into two views?

Sketch your own answer first, then compare it with the one below.

A strong answer

All-to-all heartbeats cost a message per pair per interval, which grows with the square of the cluster. The usual shapes are a central monitor, which is simple but is itself a point of failure and a hot spot, or a gossip style scheme where each node heartbeats a few peers and suspicion is passed along with the gossip, which scales but takes longer for a suspicion to reach everyone.

Whatever the topology, a suspicion is local knowledge. Node A suspecting node B does not mean B is dead, and during a partition both sides will suspect each other. Decisions that need one answer, such as who is the leader or which side keeps serving writes, must not be made from a local suspicion. They go through a quorum: the side that can still reach a majority proceeds, the other side stops.

Two tricks cut false alarms. With indirect probing, a node that misses a heartbeat asks a few others to probe the target before suspecting it. With incarnation numbers, a node that was wrongly suspected refutes the rumour by announcing a newer version of itself. Finally, keep the detector's output apart from the action: a suspicion goes into a view, and a quorum of views drives membership changes.

Sources

Learn it by running it

The failure detection lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms