April 18, 2024 4 min read A to Z Series: G Home

Gossip Protocols: Small Messages, Shared State

Gossip spreads state by having nodes periodically share what they know with a few peers.

I like gossip protocols when the system can tolerate knowledge spreading gradually. I recommend them for membership and soft state problems where simple repeated messages beat one fragile central source.

It is good for awareness, not instant agreement

I care less about the sunny-day flow and more about what happens during delay, duplication, and loss.

A gossip protocol can spread membership, load, feature flags, or cache hints. It is not the same as consensus. Gossip helps nodes become aware. Consensus helps nodes agree on one committed decision.

Cluster membership example

The point here is to move from concept to operation: who uses it, what breaks, and what decision changes.

Node A learns that Node D is unhealthy. Instead of calling every node directly, it tells Node B and Node C. They pass that fact along during their next gossip round.

Gossip merge code

I use code here to show the rule the team would actually maintain.

Each node merges what a peer knows and passes the merged view along:

void gossip(Node self, Node peer) {
  ClusterState merged = self.state().merge(peer.state());
  self.update(merged);
  peer.update(merged);
}

Each peer merges the other peer's state and updates both sides. Repeating this cheap exchange spreads membership or health information through the cluster over time.

Sequence diagram: a fact spreads through the cluster

a fact spreads through the cluster The fact spreads gradually. The design accepts short disagreement while the cluster catches up. sd a fact spreads through the cluster Node A Node A Node B Node B Node C Node C Node E Node E Node F Node F Share that Node D missedheartbeats. Share the same observation. Pass the observation in the next round. Pass the observation until the clusterconverges.

The fact spreads gradually. The design accepts short disagreement while the cluster catches up.

The propagation choice

Continue with membership

Written by Arunkumar Ganesan.

What I learnt is that gossip is not about instant truth; it is about steady convergence under messy network conditions.

#DistributedSystems #GossipProtocol #ClusterManagement #Architecture