GOSSIP PROTOCOL

Epidemic dissemination in O(log N) rounds

L214 MINDISTRIBUTED SYSTEMS
PREDICT

16 nodes spread a rumour by push gossip: each round, every node that knows it tells 2 random peers. 30% of messages are lost. After a few rounds 12 nodes know. What usually limits the next round?

Gossip spreads state the way a rumour spreads. Each round, a node picks a few random peers (the fanout) and tells them what it knows. The informed set roughly multiplies each round, so N nodes hear it in about log N rounds. There is no coordinator, and any single message, link or relay can fail.

The catch is the tail. In push gossip only informed nodes talk. Near the end almost every message lands on a node that already knows. The last few nodes wait to be picked by luck. In push-pull every node contacts a peer each round and they exchange both ways, so a node that is missing the rumour asks for it.

▶ SIMULATION
CLUSTER · PUSH
round 0 / deadline 5
fanout 2 · loss 30%
N1 has the rumour; nobody else does
WHO KNOWS (·rK = learned in round K)
N1·r0 N2·? N3·? N4·? N5·? N6·? N7·? N8·?
N9·? N10·? N11·? N12·? N13·? N14·? N15·? N16·?
live nodes informed: 1 / 16
TRAFFIC
contacts 0
lost 0 · to dead node 0
informed per round: 1
✓ every live node knows the rumour within 5 rounds
SCHEDULE
01[SYS]push gossip, loss forced to 0%
02[CLUSTER]round 1
03[CLUSTER]round 2
04[CLUSTER]round 3
05[CLUSTER]round 4
06[CLUSTER]round 5
07[SYS]report
Start of ideal: push, no loss scenario. 7 steps.
Gossip, one round (every T ms):

PUSH (only informed nodes talk):
  if I know the rumour:
    for FANOUT random peers: send(rumour)

PUSH-PULL (everyone talks, both directions):
  for FANOUT random peers p:
    exchange digests with p
    if p knows something I lack: pull it
    if I know something p lacks: push it

Why push-pull finishes faster:
  early on, few nodes know: push does the work
  late, few nodes are missing: each missing node
  asks a random peer, which almost surely knows,
  so stragglers fix themselves (pull)

Rounds to inform N nodes: O(log N) for both;
  push-pull removes most of the slow tail.

Used in: Cassandra and ScyllaDB (cluster state),
  SWIM / memberlist (Consul, Serf), Redis Cluster bus,
  anti-entropy repair in Dynamo-style stores.

Watch “live nodes informed” and the per-round counts. PUSH + MESSAGE LOSS stalls at 15 of 16. N13 is picked three times in round 4, and every one of those contacts is lost; in round 5 nobody picks it. FIX: PUSH-PULL informs all 16 by round 4 under the same 30% loss and the same fanout, and pays for it with twice the contacts. PUSH + FAILED NODE shows the other strength: the dead N9 absorbs 4 contacts and the rumour routes around it.

TUNE IT NOT YET

Keep MESSAGE LOSS at 30%. Push gossip has to reach all 16 nodes within 5 rounds. Find the smallest FANOUT that makes it, then compare the contact count with FIX: PUSH-PULL at fanout 2.

GOAL: loss = 30%, every node informed within 5 rounds, and one less fanout would miss

FIX IT NOT YET

Return this round's contacts as [from, to] index pairs. The network turns each contact into a two-way digest exchange (if either side knows, both know) and drops some of them. The starter is push gossip: only nodes that already know reach out, so the last stragglers wait to be picked by luck. Make it push-pull: every live node contacts fanout distinct random peers other than itself. Crashed nodes send nothing. Use rng() (a float in [0, 1)) for randomness.

Mental model:

gossip trades bandwidth for robustness: every node hears the news along many random paths, so no message, link or relay is load-bearing. Growth is exponential at the start and slow at the end. Push carries the news while few know; pull finishes the job when few are missing.

IN PRODUCTION

Cluster membership and failure detection (SWIM, HashiCorp memberlist in Consul and Nomad, Cassandra and ScyllaDB gossip), the Redis Cluster bus, and anti-entropy repair in Dynamo-style stores. The tuning knobs are the same as in the sim: gossip interval, fanout, and how many rounds you can wait.

IN INTERVIEWS

“How would you propagate membership changes to 1,000 nodes without a coordinator?” Describe a gossip round, why it converges in O(log N) rounds, why push stalls at the tail and push-pull does not, how fanout trades traffic for speed, and how failure detectors use the same channel to spread suspicion.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.

USED IN

Chapters that build on this lesson.

NEXT: SPLIT BRAIN →