Gossip, Membership and Failure Detection

Topics Covered

Failure Detection

The fundamental ambiguity

Unreliable failure detectors

Measuring a detector

The cost of false positives

The cost of false negatives

Two decisions, not one

Local versus global views

Gray failures

Where detection lives

Timeouts are everywhere

Crash stop, crash recovery and Byzantine faults

Detection inside one machine

Accrual and binary outputs

What this lesson builds toward

Every distributed system needs to know which of its machines are alive. Leaders must be replaced when they die, requests must stop going to crashed replicas, and data must be re-replicated when a node is gone for good. But in an asynchronous network, a crashed node and a slow one look exactly the same from the outside. This section explains what failure detectors can and cannot promise, how they are measured and why every practical detector is a trade between speed and accuracy.

The fundamental ambiguity

When node A stops hearing from node B, there are several explanations. B may have crashed. B may be alive but paused in garbage collection. The network between them may be dropping packets, while B is fine and talking to everyone else. Or B may simply be overloaded and slow to respond. A cannot tell these apart, because all it observes is silence. The impossibility result from the consensus lesson rests on exactly this ambiguity, and every failure detector is a policy for acting under it.

Unreliable failure detectors

Chandra and Toueg formalized failure detectors in 1996 as modules that output a list of suspected processes. A detector is described by two properties. Completeness: every crashed process is eventually suspected by every correct process. Accuracy: correct processes are not suspected, or at least not forever. A perfect detector has strong completeness and strong accuracy, but it cannot be built in an asynchronous system. The eventually perfect detector, which may make mistakes for a while but eventually stops suspecting correct processes, is enough to solve consensus, which is why Raft and Paxos work in practice once the network behaves.

Measuring a detector

Chen, Toueg and Aguilera proposed quality of service metrics that let engineers compare detectors. Detection time is how long after a crash the detector starts suspecting. Mistake rate is how often it wrongly suspects a correct process. Mistake duration is how long a wrong suspicion lasts before being corrected. Query accuracy is the probability that, at a random moment, the detector output is correct. These metrics make the trade off concrete: shortening detection time raises the mistake rate, and the right balance depends on the cost of each kind of error.

A crashed node and a paused node both go quiet. From the outside there is no way to tell them apart, so both get suspected.

The cost of false positives

A false suspicion is not harmless. When a healthy leader is wrongly declared dead, the cluster runs an election, rejects in flight requests and may move leadership back and forth. When a healthy storage node is declared dead, the system starts copying its data elsewhere, consuming network and disk bandwidth, and that load can slow other nodes enough that they too are suspected, causing a cascade. Many large outages began as a few false suspicions that triggered recovery work which overloaded the cluster.

The cost of false negatives

A missed failure is also costly. Requests keep going to a dead node and time out, adding latency for clients. A dead leader is not replaced, so writes stall. Data with one replica on a dead node runs with reduced redundancy, and a second failure could lose it. The longer detection takes, the longer these costs accumulate. Systems that serve interactive traffic usually want detection in seconds, while systems that move large amounts of data on failure are deliberately slower to avoid unnecessary copies.

Two decisions, not one

Good designs separate two decisions. The first is suspicion: stop sending requests to a node that seems unhealthy, route around it and maybe start a leader election. This should be fast and cheap to reverse. The second is declaring permanent failure: remove the node from the membership and re-replicate its data. This is expensive and should be slow, often minutes or a human decision. Cassandra, for example, marks nodes down quickly for routing but never removes them from the ring automatically; an operator must decommission or replace them.

Local versus global views

A failure detector runs at each node and gives that node a local opinion. Different nodes may disagree: a node behind a partial network partition might be suspected by half the cluster and trusted by the other half. Some systems accept disagreement and let each node route by its own view. Others need agreement, for example on who is in the cluster, and must turn local suspicions into a global decision through gossip or consensus. The rest of this lesson builds from local detection to cluster wide membership.

Gray failures

Gray failures are partial failures that a simple detector misses: a node answers heartbeats but serves requests slowly, a disk returns errors for some files, or a network card drops a fraction of packets. Microsoft researchers showed that gray failures cause a large share of cloud incidents, because the health check says the node is fine while users suffer. Detecting them requires checking the actual work, such as request latency and error rates observed by clients, not just whether a process answers a ping.

Where detection lives

Failure detection appears at many layers. Load balancers health check backends. Consensus protocols use election timeouts. Gossip based databases run phi accrual detectors. Kubernetes uses node heartbeats through leases and liveness probes for containers. Service meshes eject hosts that return too many errors, a technique called outlier detection. Each layer uses the same ideas with different time scales and consequences.

Timeouts are everywhere

Even systems without an explicit failure detector make failure decisions through timeouts. A client that waits two seconds for a database response and then gives up has decided, for that request, that the database is unavailable. A connection pool that closes idle connections after a minute has decided they are probably dead. These implicit detectors interact: a client retry after a timeout adds load to a server that was merely slow, making it slower still. Understanding failure detection as a design problem helps align these scattered timeouts so they reinforce each other instead of fighting.

Crash stop, crash recovery and Byzantine faults

Failure detectors usually assume crash faults: a node either works correctly or stops. Real nodes also crash and recover, returning with some state lost or stale, and the detector must handle a node that was declared dead and then reappears. Incarnation numbers, generation counters and fresh node identifiers on restart all address this. Byzantine faults, where nodes send wrong or malicious messages, are out of scope for ordinary detectors; a node that lies about its health or about others needs authentication and Byzantine tolerant protocols instead.

Detection inside one machine

The same ambiguity exists on one machine at a smaller scale. A watchdog thread that checks whether a worker thread has made progress must choose a timeout, and a worker blocked on slow disk input looks the same as one stuck in a deadlock. Kubernetes liveness probes face this inside a container: a probe that times out restarts the container, which is the right response to a deadlock and the wrong one to a temporary load spike. Many production incidents involve liveness probes restarting healthy but busy containers, turning load into outages.

Accrual and binary outputs

Traditional detectors produce a binary answer, trusted or suspected. Accrual detectors produce a continuous suspicion level, and each application chooses its own threshold. A load balancer might stop sending new requests at a low threshold, while a replication manager waits for a much higher one before copying data. This lets one detector serve several consumers with different costs of error, which is a cleaner design than running separate detectors with separate timeouts.

What this lesson builds toward

The next sections move from single detectors to cluster wide protocols: adaptive heartbeats that learn normal timing, gossip that spreads information without a coordinator, SWIM that combines both with constant load and the ways real systems mix these with consensus. Throughout, keep the central ambiguity in mind, because every design choice is a way of living with it.

Separate suspicion from removal

A detector cannot tell slow from dead. Make suspicion fast and cheap to reverse, so traffic routes around trouble quickly, and make permanent removal slow and deliberate, so false alarms do not trigger expensive recovery.