← Lessons

quiz vs the machine

Platinum1740

System Design

The Gossip for Presence

Spreading membership and presence state across nodes by having each periodically exchange with random peers.

5 min read · advanced · beat Platinum to climb

What it is

A gossip protocol spreads state across a cluster without any central coordinator. Each node periodically picks a random peer and exchanges what it knows. Like a rumor, information reaches everyone in a number of rounds that grows only logarithmically with cluster size.

Why presence uses it

A presence system across many nodes must agree on who is online. Gossip distributes this membership cheaply and tolerates node failure, because no single node is responsible for the whole picture.

  • Each node tracks a heartbeat counter per member.
  • On each round it merges its view with a peer, keeping the highest counter seen.
  • A member whose counter stops rising is eventually marked failed.

Tradeoffs

  • State is eventually consistent, so two nodes may briefly disagree.
  • Gossip uses constant bandwidth per node regardless of cluster size.
  • Tuning the round interval trades convergence speed against traffic.

Key idea

Gossip spreads presence and membership by having each node exchange heartbeat counters with random peers, converging the whole cluster cheaply and tolerating failure without a coordinator.

Check yourself

Answer to earn rating on the learn ladder.

1. How does information spread in a gossip protocol?

2. What consistency does gossip provide for presence state?