Distributed patterns / Advanced / 5 min / Updated
Gossip protocol and failure detection: heartbeats and timeouts
Kill a node and watch the news spread. Compare a central monitor, all-to-all heartbeats and gossip, and see short timeouts flag healthy nodes.
Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.
In short
What is gossip protocol?
Gossip spreads membership and failure news by each node telling a few random peers every round.
Why does it matter?
Large clusters need to agree on who is alive without a central monitor or n-squared heartbeats.
What is the trade-off?
Scales well and has no single point of failure, but news takes a few rounds; timeouts trade speed for false alarms.
How do you explain it in an interview?
"Gossip-based membership like Cassandra, with a phi accrual detector instead of a fixed timeout."
Check yourself
Why do large clusters avoid all-to-all heartbeats?
Answer: Messages grow with the square of the node count. 1,000 nodes pinging each other is about a million messages a second.
How does gossip spread news of a dead node?
Answer: Each node tells a few random peers each round, so it reaches everyone in about log(n) rounds. Like a rumour: the number who know multiplies each round.
What is the risk of a very short failure timeout?
Answer: Healthy but briefly slow nodes are marked dead, causing needless failovers. GC pauses and network blips look like death; adaptive detectors like phi accrual reduce this.