Gossip keeps everyone informed

Gossip is an epidemic-style background protocol where every node periodically exchanges state with one random peer; the cluster converges to a consistent membership view in O(log N) rounds with no master.

Previously

Reads, hints, and repairs all need the cluster to know who's alive — that membership picture is itself maintained by a quiet background protocol.

Scene 11a

Gossip — every node, every second, one random peer

  1. Watch
  2. Try it
  3. Predict
  4. Capture
gossip protocoleach tick: every node picks a random peer and exchanges stateROUNDS0INFORMED1 / 8ABCDEFGH8-node clusterno masterRound 0 — only the seed node knows the new state.
What to watch for

Node A has just heard a new piece of state — say, 'node X is down'. Watch one round of gossip at a time: each node picks a random peer and exchanges state. The informed set roughly doubles per round, so 8 nodes converge in about log₂(8) = 3 rounds. No master, no broadcast — just pairwise chatter.

Continue unlocks when the animation finishes.
Implementation

Highlighted lines are the ones running in the diagram right now.

Node.gossip_round
one tick — pick a peer, swap state, take the union
def gossip_round():
peer = random.choice(peers - {self})
digest = self.state.versions() # {key: version}
delta = peer.exchange(digest)
# delta = entries peer has at >= our version
self.state.merge(delta)
# informed set roughly DOUBLES per round →
# cluster converges in O(log N) rounds
Node.exchange
per-key max merge — the convergence engine
def exchange(peer_digest):
delta = {}
for key, peer_v in peer_digest.items():
if peer_v > self.state[key].version:
# peer has fresher; we'll take it on merge
pass
elif self.state[key].version > peer_v:
# we have fresher; ship it back
delta[key] = self.state[key]
return delta
Node.scheduler
every node runs gossip_round on a fixed period
# runs on every node, forever, with no master
loop forever:
gossip_round()
sleep(gossip_period_ms) # ~1s in Cassandra

Where this sits in Build a wide-column store (Cassandra / DynamoDB family)

Scene 11a of 13, in the Healing act — Hinted handoff + read repair + anti-entropy + gossip keep the cluster honest.. Each node, every second, swaps state with a few peers; the cluster picture converges without a master.

Up next. We now have every primitive; the closing scene puts them together against a real workload.

All 13 scenes in Build a wide-column store (Cassandra / DynamoDB family) · Every curriculum

Built with Arqly
Every scene in Build a wide-column store (Cassandra / DynamoDB family) builds on the one before it.All 13 Build a wide-column store (Cassandra / DynamoDB family) scenes