EMZETT.
Login

Distributed consensus (Paxos and Raft)

In short: Consensus protocols such as Paxos and Raft let several servers agree on one value or an order of commands even if individual servers fail.

In more detail: A cluster elects a leader that accepts writes and distributes them to followers through a log. An entry counts as committed once a majority (quorum) has stored it. If the leader fails, a new one is elected.

In Depth

  • Quorum: Majority of n nodes, that is ⌊n/2⌋+1. A 5-node cluster survives 2 failures.
  • Raft: Clearly structured: leader election, log replication, safety. Used in etcd, Consul.
  • Paxos: Older, harder to understand; variants in Chubby and Spanner.
  • Epochs/terms: Number leader tenures so old leaders can no longer overwrite anything.
  • Limits: More nodes mean more communication and higher latency. During a network partition only the majority stays functional (see CAP).
  • Use: Configuration stores, leader election, distributed locks.

See also: CAP theorem, Replication: leader and follower