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.
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
- Watch
- Try it
- Predict
- Capture
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.
Highlighted lines are the ones running in the diagram right now.
def gossip_round():peer = random.choice(peers - {self})digest = self.state.versions() # {key: version}delta = peer.exchange(digest)# delta = entries peer has at >= our versionself.state.merge(delta)# informed set roughly DOUBLES per round →# cluster converges in O(log N) rounds
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 mergepasselif self.state[key].version > peer_v:# we have fresher; ship it backdelta[key] = self.state[key]return delta
# runs on every node, forever, with no masterloop 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