Gossip protocols (epidemic algorithms) propagate information through a cluster via periodic, pairwise state exchanges. They are the standard for decentralized membership and failure detection in large-scale systems (Cassandra, Consul, Dynamo).

Mathematical Model: Infection Rate

Information spread in a gossip network follows the logic of a viral infection. In a cluster of Nnodes, if each node gossips withkrandom neighbors everyTseconds, the time to achieve full convergence (t_{conv}) is:

t_{conv} \propto \frac{\log(N)}{\log(k)}

Gossip is highly resilient: even if$50%of nodes fail, the rumor still reaches all surviving nodes withO(\log N)$latency.

Protocol Variants

  1. Push: Node A sends its state to Node B. (Fastest for new data).
  2. Pull: Node A requests state from Node B. (Most efficient for catch-up).
  3. Push-Pull: Bidirectional exchange. (Optimal convergence, higher bandwidth).

Use Cases

1. Membership management (SWIM)

SWIM (Scalable Weakly-consistent Infection-style Membership) decouples failure detection from membership updates.

2. Failure Detection (Phi Accrual)

Instead of a binary "Up/Down" state, nodes track the inter-arrival time of heartbeats.

3. State Propagation

Propagating configuration or ring topology. Implementation (Pseudo-Code):

def gossip_round(local_state):
    # Pick k random peers
    peers = random.sample(cluster_nodes, k)
    for peer in peers:
        # Push-Pull: Send what I know, ask what they know
        remote_delta = peer.exchange(local_state.summary())
        local_state.merge(remote_delta)

Comparison: Gossip vs. Consensus

MetricGossip (Epidemic)Consensus (Raft/Paxos)
ConsistencyEventualStrong (Linearizable)
Scalability$10,000+nodes |<100$nodes
CoordinationPeer-to-peerLeader-based
Typical UseFailure detection, metadataTransactions, locks

Operational Risks