Skip to content

CONCEPT Cited by 1 source

Peer sampling service

The peer sampling service (PSS) is the abstraction that hands a gossip implementation its next peer on each round. It hides the question "who do I talk to?" behind a small API, so the gossip mechanism itself never needs a full member list.

Why it exists

Gossip's O(log_fanout N) convergence depends on the random peer choice. A trivial implementation would need to know every node in the system to pick one uniformly — but that re-introduces the full-member-list cost that gossip exists to avoid. PSS is the resolution: each node keeps a partial view (a small random subset of the membership), refreshed via gossip itself.

API (from the post)

From sources/2023-07-16-highscalability-gossip-protocol-explained:

  • /gossip/init — returns the list of nodes known to a particular node at startup.
  • /gossip/get-peer — returns the address (IP + port) of an independent peer node.

Workflow

  1. Initialise each node with a partial view — typically seeded from the seed-node list.
  2. On each gossip round, call get-peer to pick a peer.
  3. On exchange, merge the peer's view with the local view — so each successful cycle also updates the membership snapshot.

This bootstraps: a node's view grows and gets fresher purely as a side effect of the gossip exchange it would have done anyway.

Selection policies (from the post)

  • Uniform random (e.g. Java java.util.random).
  • Least-recently-contacted — bias toward nodes with stale heartbeat.
  • Network-topology-aware — weight by rack/zone proximity.

Probabilistic distributions help "reduce duplicate message transmission to the same node."

Reference implementations

  • Cassandra — seed nodes + periodic shuffle of the gossip state.
  • Serf / SWIM — indirect-ping selects k random peers for liveness probes.
  • Fly.io Corrosion — SWIM-style PSS sitting over a fully-connected WireGuard mesh, so the "network" sub-problem is free; "all we need to do is gossip efficiently" (Source: sources/2025-10-22-flyio-corrosion).

Seen in

Last updated · 319 distilled / 1,201 read