Overview
Gossip, or epidemic, protocols disseminate information the way rumors spread. Each node periodically talks to random peers, so updates reach the whole cluster without any central coordinator. Cassandra, Consul and Redis Cluster use it for membership and metadata.
How it works
Each round a node selects a small fanout of peers, sends a digest of what it knows, and receives what the peer knows that is newer.
every 1s:
peers = random(k=3, liveNodes)
for p in peers:
send digest { nodeId: version, ... }
p replies with entries newer than digest
merge by max(version) per nodeId
Convergence takes roughly log base fanout of N rounds, so 1000 nodes converge within about ten rounds. SWIM-style failure detection pings a random node, and on timeout asks several others to ping it indirectly before marking it suspect. A suspect node can refute by incrementing its incarnation number.
Pitfalls
- Aggressive timeouts cause false positives during long GC pauses or noisy neighbors.
- Without tombstones and expiry, deleted entries return; with tombstones that expire too soon, they return anyway.
- Seed node misconfiguration can create separate clusters that never merge.
- Gossip carries small metadata only; do not push bulk data through it.
- Partitions produce different views on each side, so never use gossip state for decisions needing strict agreement such as leader election.
Key takeaways
- Random peer exchange spreads data in log N rounds with bounded per-node load.
- Use versions or heartbeat counters so merges are idempotent.
- Treat gossip views as eventually consistent hints, not truth.
- Tune interval, fanout and suspicion timeout against real network behavior.