01 / 07 · THE PROBLEM
Five replicas. One dropped message.
Two different truths.
CONSENSUS
S1 S2 S3 S4 S5 $1000 $1000 $900 ? ? ? $1000 message lost SPLIT BRAIN
QUORUM majority = N2 + 1  =  3 of 5  —  any two majorities overlap
NARRATIONFive servers, one dropped packet — and now two of them believe different things.
02 / 07 · PAXOS · LAMPORT, 1998
Promise, then accept. Two phases, one chosen value.
PAXOS
PHASE 1 — PREPARE / PROMISE P proposer A B C PREPARE(n = 7) PROMISE(7) no reply MAJORITY PROMISED — 2 of 3 PHASE 2 — ACCEPT / ACCEPTED P x = 42 A B C ACCEPT(7, x = 42) ACCEPTED(7, 42) VALUE CHOSEN — IRREVERSIBLE
SAFETY N2+1 promises  ∧  N2+1 accepts  ⇒  value chosen forever
NARRATIONA majority promise, plus a majority accept, equals agreement no crash can undo.
03 / 07 · THE COST OF ELEGANCE
Beautiful on paper. Brutal to implement.
MULTI-PAXOS
CONCURRENT PROPOSERS N1 N2 N3 N4 competing proposals, repeated rounds THE LOG HAS GAPS 1 2 — 4 — 6 7 8 holes must be filled out of band · leader election lives OUTSIDE the algorithm · membership change: an extension · snapshotting: an extension JUST TRUST THE PROOF
REALITY Multi-Paxos  =  Paxos  +  leader  +  gap filling  +  membership  +  snapshots
NARRATIONFor decades students were told to trust the proof — because almost nobody could ship it.
04 / 07 · RAFT · ONGARO & OUSTERHOUT, 2014
Three states, numbered terms, one direction.
RAFT
FOLLOWER passive, hears heartbeats CANDIDATE asks for votes LEADER replicates the log election timeout majority of votes split vote → new timeout sees higher term → steps down TERMS AS EPOCHS term 1 term 2 term 3 → a stale leader is rejected instantly
RULE term > termcurrent  ⇒  old leader demoted  ·  log flows leader → follower only
NARRATIONA follower that stops hearing heartbeats starts an election and asks for votes.
05 / 07 · LOG REPLICATION & SAFETY
Committed means a majority stored it.
REPLICATION
LEADER 1 2 3 4 5 6 F1 1 2 3 4 5 F2 1 2 3 4 F3 1 2 3 4 F4 1 2 3 4 commit index = 4 stored on 4 of 5 → committed THE UP-TO-DATE VOTE RULE a candidate only wins votes from servers whose log is at least as up to date as its own ⇒ committed entries are never lost, never overwritten
COMMIT committed  ⟺  entry stored on  N2 + 1 nodes
NARRATIONAn entry is committed the moment a majority stores it — and it is never overwritten.
06 / 07 · HEAD TO HEAD
A theorem, or an architecture?
COMPARISON
CRITERION PAXOS · 1998 RAFT · 2014 Quorum required majority majority Tolerates f failures yes · 2f + 1 yes · 2f + 1 What it specifies one value a replicated log Leader election outside the algorithm built in Membership change an extension built in Snapshotting an extension built in
VERDICT Paxos gives you a theorem  ·  Raft gives you an architecture
NARRATIONPaxos specifies agreement on a single value. Raft specifies the whole system.
07 / 07 · WHERE THEY RUN
Consensus is hard. Clarity makes it possible.
IN PRODUCTION
RAFT TODAY etcd Consul TiKV CockroachDB log replication · leader election · membership · snapshots PAXOS TODAY Chubby Spanner agreement on a single value, scaled by careful engineering A correct algorithm nobody can implement is worth less than a correct algorithm everybody can.
SUMMARY safety  ∧  liveness  ⇒  consensus  ·  quorum  =  N2 + 1
NARRATIONThe lesson is not that one is better — it is that clarity is what makes consensus possible.