Gossip protocols

Gossip protocols

Gossip protocols solve the problem of maintaining a consistent global view of the network while having a set of unstructured & unreliable network participants.

They do this by mimicking pandemic or gossip protocols, which have been studied in depth since early 20th Century.

The protocol is relatively simple and lightweight, although it could get "bit chatty" as the current global state needs to be broadcasted constantly throughout the whole network for guaranteed consistency.

  • Distributed: No need for every node to communicate with each nodes in the network.
  • Robust: It tolerates faulty nodes dropping connection, leaving or rejoining the network at any time.
  • Fast: Information is quickly spread.

Steps

  • Initial peer discovery
      • When first booting, a node will dynamically obtain a list of bootstrap peers from a base node.
  • Every node periodically exchanges info with any chosen neighbour. The payload gets transmitted over and then this information is consolidated by the node.
  • One round involves: Node selection + information exchange. Eventually, the state of all nodes will convert to a common state at the end of execution.

Eventual consistency: Even with a very small number of nodes infected in each round, there is a payload is spread across the network and eventually all nodes get infected that is to say, they receive the global network state.

This is a Java implementation from Apache which was originally retired; it was using really old libraries and code practices; I took it as a challenge and I'm currently in the process of updating it while I'm enjoying learning more about it. It now runs on Java 21 using fancy libs like Lombok.

Both Git repo and CI (Provided by Drone) are self hosted.

gossip-revisited
Java implementation for a Gossip protol