Part IV — Peer-to-Peer & Decentralized Data · Chapter 1

Gossip protocols & epidemic dissemination

Hook

One node in a network of 8 learns something new. There's no server, no broadcast channel — just peers who occasionally talk to a few other peers. How does the whole network find out?

Intuition
01.010.020.030.040.050.060.070.0
round 0 — 1 of 8 nodes have heard the rumor

Click "gossip one round" a few times. Node 0 tells a couple of neighbors, then those nodes each tell a couple more — the highlighted ring shows exactly who just heard the news this round. Nobody ever had to contact all 8 nodes directly; the rumor spreads through the network itself.

Formalize

In an anti-entropy / push gossip protocol, every node that knows a piece of information (is "infected") contacts a small, bounded number of peers — its fanout — each round. Any peer it contacts becomes infected too, and joins in spreading next round:

It+1  =  ItvItgossip(v,t,k)I_{t+1} \;=\; I_t \,\cup\, \bigcup_{v \,\in\, I_t} \text{gossip}(v, t, k)
  • ItI_t — the set of nodes that have heard the rumor after round tt (round 0 is just the one starting node).
  • gossip(v,t,k)\text{gossip}(v, t, k) — the up-to-kk peers node vv contacts during round tt, drawn from its fixed neighbor list.
  • kk — the fanout: how many peers each infected node contacts per round.
  1. Growth compounds, it doesn't add

    Because every currently-infected node gossips simultaneously each round — not just the original source — the infected set can multiply round over round instead of only growing by a fixed amount, the way epidemics spread through a population.

  2. Fanout trades speed for chatter

    A larger fanout reaches full coverage faster, at the cost of more messages sent per round. A fanout of 1 is the cheapest per round but the slowest to converge; a fanout equal to a node's full degree (flooding) is fastest but sends the most messages.

Play
01.010.020.030.040.050.060.070.0
round 0 — 1 of 8 infected — fanout 2 reaches everyone in 3 rounds

Drag the fanout slider down to 1, gossip forward, and watch how much longer it takes to reach every node — and how it can even stall for a round with nothing new happening, simply because this round's rotation of peers hasn't reached the last holdout yet. Push fanout up to 3 and the same 8-node network gets fully infected in half the rounds.

Worked example

Same fixed 8-node network (each node has exactly 3 neighbors — a ring plus one long "shortcut" to the node directly opposite it), starting from node 0:

  1. Fanout 2, round by round

    Peer selection rotates through each node's neighbor list by offset = round mod 3, contacting the next 2 neighbors from there:

    1. Round 1 (offset 0): node 0's neighbors are [1,4,7][1,4,7], so it contacts the first two, 11 and 44 → infected ={0,1,4}=\{0,1,4\}
    2. Round 2 (offset 1): node 0 contacts [4,7][4,7] (its neighbors shifted by 1), node 1 contacts [2,5][2,5], node 4 contacts [3,5][3,5] → infected grows to {0,1,2,3,4,5,7}\{0,1,2,3,4,5,7\} — seven of eight
    3. Round 3 (offset 2): nodes 2, 5, and 7 each shift to contacting 66 as one of their two targets — the last holdout finally gets reached → all 8 nodes infected
  2. Fanout 1 takes noticeably longer

    With only one peer contacted per round (just offset's neighbor, no second target):

    1. Round 1: infected ={0,1}=\{0,1\}
    2. Round 2: infected ={0,1,2,4}=\{0,1,2,4\}
    3. Round 3: infected ={0,1,2,4,5,6,7}=\{0,1,2,4,5,6,7\}
    4. Round 4: stalls — every infected node's single round-4 target already belongs to the set
    5. Round 5: node 3 finally gets reached — all 8 nodes infected

    Needing 5 rounds total to fully cover.

  3. Fanout 3 (flooding) is fastest

    Contacting every neighbor every round reaches all 8 nodes in just 2 rounds — the fastest possible for this graph, at triple the per-round message cost of fanout 1.

Checkpoint

Pick a fanout (1, 2, or 3) so the rumor reaches all 8 nodes within 3 rounds, then gossip forward and confirm it.

01.010.020.030.040.050.060.070.0
round 0 — 1 of 8 infected — full coverage at round 5
Pick a fanout and gossip forward
Summary
It+1=ItvItgossip(v,t,k)I_{t+1} = I_t \cup \bigcup_{v \in I_t} \text{gossip}(v, t, k)

Gossip protocols get information everywhere without anyone needing a full membership list or a central broadcaster — every node just needs to know a few peers. The fanout kk is the one knob that trades speed (fewer rounds to full coverage) against chatter (more messages per round), and the same rule underlies both "rumor spreading" and, later in this part, keeping cluster membership itself up to date.