Goal

After this module you can translate any step of Raft into the matching step of Multi-Paxos (PMMC) and back, state and prove the one quorum lemma that both safety proofs rest on, explain the single real design difference (who may become leader), count the round trips of a write with and without a leader change, and judge claims such as “Paxos is leaderless” or “Raft needs fewer round trips”.

Modules 5 to 7 built Raft; Module 8 and Module 9 built Paxos and Multi-Paxos. The two look very different on paper: Raft has terms, logs and two RPCs; PMMC has ballots, slots and five kinds of processes. Lecture 10.03 advises learning Raft first, then Paxos, and then carrying the high-level picture from one to the other. This module does that carrying.

The main message is due to Howard and Mortier (1): once both are written in the same vocabulary, the protocols agree almost everywhere. They differ in one place, the election. Raft elects only a candidate whose log is already complete; Paxos lets any proposer lead and makes it learn what it is missing during Phase 1. Every other difference (the Figure 8 rule, the direction of log repair, holes in the log) follows from this choice.

Both are total order broadcast

What service do the two protocols provide? Both turn a stream of client commands into one sequence that every replica applies in the same order: a total order broadcast (Definition 4.3), which is equivalent to consensus (Theorem 4.11). Delivering a message means applying a log entry (Raft) or executing a decided slot (PMMC). They differ in which total order they produce, and this places them at slightly different points of the hierarchy of Module 1 (Theorem 1.13).

Raft orders commands by arrival at a leader. A leader appends commands to its log in the order it receives them and never reorders its own log (Proposition 6.7). Kleppmann accordingly presents Raft as an algorithm for “fault-tolerant FIFO-total order broadcast” (2).

Proposition 10.1 (Raft keeps each leader's arrival order).

Let the leader of term append commands and then to its log, at indices . If any server applies the entry , then every server that applies entries up to index applies at index first.

The proposition is the FIFO property for one sender talking to one leader over a FIFO link. Across a leader change it needs help from the client: a command that was appended but never committed is lost, and the client must resend it, possibly after later ones. Clients that number their requests and send the next one only after the previous one is acknowledged get FIFO-total order in either protocol (Remark 4.12 makes the same point for the consensus-based construction).

Multi-Paxos orders commands by slot, and slots are assigned per command. In PMMC a replica proposes each request for a slot; if another command wins that slot, the replica re-proposes its request for a later slot. Nothing ties the slot order to the order in which one client sent its requests, even without any failure.

Example 10.2 (PMMC reorders one client's commands).

Two replicas R1 and R2 and a stable leader. A client sends and then to R1; another client sends to R2. R1 proposes for slot 1 and for slot 2; R2 proposes for slot 1, and R2’s proposal reaches the leader first. The leader decides slot 1 as and slot 2 as . R1 sees that its proposal for slot 1 lost and re-proposes , which lands in slot 3. Every replica executes : a total order, but before .

So both protocols implement total order broadcast. Raft, through its single leader per term and append-only leader log, gives FIFO order within each leader’s term for free; PMMC as written does not. Neither gives FIFO across failures without client sequence numbers.

A dictionary

Which Raft notion corresponds to which Paxos notion? The table translates term by ballot. Read the “note” column as carefully as the other two: the dictionary is exact in some rows and only approximate in others.

ConceptRaftMulti-Paxos (PMMC)Note
leadership tokentermballot Ballots contain the leader’s id, so they are unique by construction; a term needs a vote to get a unique leader.
becoming leaderRequestVote to a majorityscout: p1a, p1b from a majorityPhase 1, run once per leader change and covering all positions.
what a voter sends backyes or noall its accepted pvaluesRaft filters, Paxos transfers (see below).
condition to winup-to-date lognonePaxos instead adopts the highest-ballot pvalue per slot (pmax).
replicating a commandAppendEntries, ackcommander: p2a, p2bPhase 2. Raft batches all positions into one RPC.
refusing a stale leaderreply with higher termp2b with higher ballotRaft: step down. PMMC: preempted.
decided positiondecision for slot Raft announces it in the next AppendEntries; PMMC sends a decision message.
applied positionBoth apply strictly in order.
repairing a lagging nodenextIndex walk-back, leader to followerp1b replies, acceptors to leaderOpposite directions.
gaps in the logimpossiblepossible, filled by later proposals or no-opsRaft logs are prefix-consistent; slots are independent.

Three rows deserve a sentence each.

  • Phase 1 is the election. Lecture 10.01 calls consensus a two-round protocol: “in the first round, … let’s use this ballot … in the second round … with this ballot, let’s use this value”. In Raft the first round is RequestVote, the second AppendEntries. In both protocols the first round runs once per leader change, not once per command.
  • Up-to-date vote versus pmax. These are the two answers to the same question: how does a new leader end up with every entry that may already be chosen? Raft makes it a precondition of winning; Paxos makes it a consequence of winning (1).
  • Walk-back versus scout. A new Raft leader pushes its log out to followers and finds the first point of agreement by walking backward from the end of each follower’s log. A new Paxos leader first pulls accepted values in from a majority, for all slots at once, and only then pushes them out under its own ballot.

One crash, two recoveries

What does the difference look like in a concrete run? Take three servers A, B and C, each acting as Raft server or as colocated PMMC replica, leader and acceptor.

Example 10.3 (The same crash in both protocols).

Before the crash, A is the leader (term 2 in Raft, ballot in Paxos). Positions 1 and 2 are on all three servers. A sends command for position 3 to B only, and B acknowledges; A counts two of three and commits (Raft) or decides (Paxos) position 3. Then A crashes. C never received .

Raft. Logs (terms): A , B , C .

  1. If C times out first and asks for votes in term 3, B compares last entries, against C’s , and refuses. C has only its own vote and cannot win.
  2. If B campaigns, C grants (B’s log is more up-to-date). B wins term 3 and already holds at index 3.
  3. B appends a no-op of term 3 at index 4 and sends AppendEntries to C. C accepts and the no-op, and B commits index 4, which commits index 3 indirectly.

Paxos. Acceptor states: A and B have accepted ; C has nothing for slot 3.

  1. C times out first and starts a scout with ballot . B and C reply to the p1a (A is down). B’s p1b carries .
  2. The scout has a majority: C is adopted. It computes pmax over the two replies; slot 3 maps to , so C replaces whatever it may have wanted to propose for slot 3 with .
  3. C’s commanders send (and the same for slots 1 and 2). B and C accept, and slot 3 is decided as a second time: harmless, it is the same command.

In both runs the committed command survives at position 3. Raft guaranteed it by refusing C; Paxos guaranteed it by letting C win and making it copy from B.

Both recoveries used the same server B, the one in the intersection of the old commit quorum and the new election quorum. The next section shows that this is no accident.

The lemma behind both safety proofs

Why must some server of the election quorum know the committed value? The argument has the same shape in Raft, in Paxos, and in the quorum reads of Module 3; it is worth stating once in general.

Definition 10.4 (Guarded writes and reads).

Every node keeps a number that never decreases. A write with number is a request that accepts only if , after which . A read with number is a request on which sets and then replies.

In Raft, is , a write with number is an AppendEntries from the leader of term , and a read with number is a RequestVote for term . In Paxos, is the acceptor’s , a write is a p2a and a read is a p1a.

Lemma 10.5 (Intersecting quorums carry memory).

Suppose every node of a set accepted a write with number , every node of a set replied to a read with number , and . Then some node of accepted the write before it replied to the read.

For Raft, Module 5 already proved this special case (Proposition 5.12). Two majorities of the same nodes always intersect (Lemma 5.8). In fact the lemma needs only (Lemma 3.14), which is the observation behind Flexible Paxos (3): Phase 1 and Phase 2 quorums need to intersect each other, not themselves.

The lemma gives a node that saw the write. It does not say that the node still reports it: between the write and the read, the node may have accepted later writes with numbers between and . Each protocol closes this gap with an induction over those intermediate numbers, and both inductions start at the smallest bad number.

StepRaft (Theorem 7.4)Paxos (C2 in Module 9)
writecommitting entry of term on a majorityvalue accepted for slot by a majority at ballot
readvotes for the leader of a term p1b replies to a scout with ballot
node of the lemmaa voter that stored before votingan acceptor that accepted before its p1b
intermediate numbersleaders of terms hold (smallest bad )commanders of ballots propose (smallest bad )
how the new leader ends up with itthe voter refuses unless the candidate is at least as up-to-datethe scout reports it and pmax picks it

The last row is the only place where the protocols differ.

Remark 10.6 (Filter versus transfer).

In Raft the voter keeps what it knows and uses it as a filter: it grants its vote only to a candidate whose log is at least as up-to-date (Definition 6.3). In Paxos the acceptor transfers what it knows to the new leader in its p1b, and the leader adopts the highest-ballot value per slot. Filtering costs nothing in bandwidth but restricts who can win; transferring lets anyone win but ships accepted state in every p1b.

The lemma also explains how an old leader learns that it has been replaced, the scenario of Kleppmann’s Slide 110 (2). Take the election of the new leader as the read and the old leader’s next replication round as the attempted write: the old leader cannot get a quorum to accept, because at least one node of every quorum has already joined the new term and answers with it (Proposition 5.12).

Why Paxos has no Figure 8 problem

Does Multi-Paxos need anything like Raft’s current-term commit rule (Definition 6.8)? No, and the reason is a small difference in bookkeeping.

In Raft an entry keeps the term in which it was created, forever. When the leader of term 4 in Figure 8 copies the term-2 entry to a majority, the copies still say “term 2”. A later candidate whose last entry has term 3 compares 3 against 2 and wins, even though the term-2 entry sits on a majority (Figure 7.2). Counting replicas of an old-term entry is therefore not enough to commit it, and Raft adds the rule that only current-term entries are committed by counting.

In Paxos a new leader renumbers: after adoption it proposes every adopted value under its own ballot. In the same situation the leader of ballot 4 sends , so acceptors record ballot 4, and any later scout that meets one of them sees ballot 4, which beats ballot 3 in pmax. A value accepted by a majority at one ballot is chosen, with no extra rule.

Exam trap: "Paxos needs a no-op to commit old entries, like Raft"

In Raft the no-op at the start of a term is needed because old-term entries cannot be committed by counting. In Paxos a new leader re-proposes adopted values under its own ballot, which commits them directly. PMMC uses no-ops for a different reason: to fill a hole, a slot for which no acceptor reported anything, so that later slots can be executed. Do not confuse the two uses.

The price of renumbering is that the new leader must re-send old values to a majority before it can be sure they are decided, which Raft avoids for entries that are already on a majority. The Figure 8 rule and the re-proposal are the same work, done at different times.

One write, message by message

How many messages and round trips does one client write cost? The animation replays the preemption scenario of Module 9 with the Raft name of every step shown next to the Paxos one.

Try it: step to the moment L2’s scout collects p1b from A1 and A2, and compare the two notes. The Paxos note says L2 re-proposes L1’s command c3; the Raft note says Raft would only have elected an up-to-date candidate. Then step on until L1’s stale p2a is rejected, which Raft calls a stale AppendEntries.

In steady state, with the leader already in place, the two protocols exchange the same messages up to naming.

Raft, steady state client leader F1 F2 request AppendEntries ack commit, apply reply leaderCommit apply Multi-Paxos (PMMC), steady state client replica leader acceptors request propose p2a p2b decision perform response
Figure 10.1. One client write in steady state. Raft: one AppendEntries round trip, the commit is told to followers in the next AppendEntries. Multi-Paxos (PMMC roles): one p2a/p2b round trip between a commander of the leader and the acceptors, then a decision to the replicas. Leader changes (RequestVote, or p1a/p1b) are not shown.
StepRaftMulti-Paxos with stable leaderSingle-decree Paxos
establish leaderRequestVote round trip, once per termscout round trip, once per ballotPhase 1 round trip, every value
get the value acceptedAppendEntries round tripcommander round tripPhase 2 round trip
tell everyonenext AppendEntries (piggybacked)decision messagelearn messages
round trips per write112

With servers and the leader colocated with a replica and an acceptor, a steady-state write costs in both protocols one message from the client, replication requests, up to acknowledgements and one reply: about messages and two message delays between leader and followers.

Lecture correction: what the "two rounds" of Raft are

Lecture 10.01 says that “consensus in general requires two round trips”, and for Raft names them as follows: the leader proposes the log entry and everybody agrees, and then the leader tells everybody the entry is committed. The first statement is right when it refers to the election and the replication. The Raft mapping is not:

  • The commit notification is not a round trip. Followers do not acknowledge it, it travels inside the next AppendEntries, and safety never depends on it; a follower that misses it learns the commit index later.
  • Raft’s analogue of Phase 1 is the election, and it runs once per term, not once per write. Kleppmann’s Slide 110 (2) draws exactly this: one round trip to become leader, one round trip per message, and a one-way “now deliver m”.

So both protocols pay two round trips for the first write after a leader change and one round trip for each write after that.

Exam trap: "Raft needs one round trip and Paxos two, so Raft is faster"

This compares Raft in steady state with single-decree Paxos. Multi-Paxos with a stable leader also needs one round trip per command, because Phase 1 is amortized over all slots exactly as Raft’s election is amortized over all entries. The fair comparison is Raft against Multi-Paxos, and there the steady-state message pattern is the same.

Leaderless versus leader-based

Lecture 06.02 sorts consensus protocols into two families: “Paxos is a leaderless consensus protocol”, and “raft is an example of a leader based consensus protocol”. In a leader-based protocol, it says, once a leader is chosen “they can sort of unilaterally make the decisions”, while a leaderless protocol needs coordination for every decision.

Lecture correction: Paxos is not leaderless, and a Raft leader does not decide alone

Two parts of the 06.02 taxonomy are misleading.

  1. A Raft leader never decides unilaterally. Every entry needs acknowledgements from a majority before it is committed; a leader that acted alone would break State Machine Safety as soon as a newer leader existed. Kleppmann’s notes say it plainly: “It is not safe for a leader to act unilaterally” (2). What the leader saves is the election, not the vote on each entry.
  2. Paxos is not leaderless. Each ballot has exactly one proposer, its leader, and Multi-Paxos keeps one leader for many slots, exactly as Raft keeps one leader for many entries. What 06.02 describes as leaderless is single-decree Paxos run once per value, in which every value pays for Phase 1 and proposers may duel.

The real distinction (Howard and Mortier (1)) is the condition for becoming leader: Raft requires an up-to-date log, Paxos requires nothing and repairs the leader’s knowledge in Phase 1. Protocols that are leaderless in the strict sense, where any replica can commit a command without a designated leader, exist but are beyond this course.

Remark 10.7 (What the taxonomy gets right).

The point of 06.02 about cost is correct: running full consensus for every decision is expensive, and every deployed system amortizes it with a long-lived leader. That is true of Raft and of Multi-Paxos alike, which is why Module 9 needed Multi-Paxos and not just Paxos.

Invariants side by side

Which Raft property corresponds to which PMMC invariant? The table pairs them; the full statements are in Module 7 and Module 9.

RaftPMMCWhat both sayDifference
stored terms never decrease (Lemma 5.5)A1the guard number only growsnone
Election Safety (Theorem 5.10)ballots unique; C1one leader per numberRaft needs votes; a ballot contains its leader’s id
Leader Append-Only (Proposition 6.7)A3recorded state is not lostRaft followers may truncate; acceptors never delete
Log Matching (Theorem 7.3)nonesame position and number gives same contentslots are independent, so PMMC needs no prefix property
Leader Completeness (Theorem 7.4)C2 and A5later leaders carry chosen valuesprecondition in Raft, consequence of pmax in Paxos
State Machine Safety (Theorem 7.7)R1 and R2one command per position at every replicanone
commit index never decreasesR4applied prefix only growsnone

The Log Matching row is the one without a partner, and it explains the “gaps” row of the dictionary. Raft’s consistency check makes logs prefix-consistent, so a Raft log never has a hole. PMMC decides slots independently: slot 5 may be decided before slot 4, and replicas simply wait (R3 and the execution loop of Module 9).

Exam trap: "a Multi-Paxos log has no holes because replicas execute in order"

The execution is in slot order, but the decisions are not. A leader may run commanders for slots 4 and 5 in parallel, slot 5 may be decided first, and after a leader change slot 4 may have no reported value at all, so the new leader must fill it with a no-op. Raft’s log, in contrast, never has a decided entry after an undecided one.

What must survive a crash

Which variables must each protocol write to stable storage before replying? The lemma answers it: whatever the guard number and the memory of a write depend on.

Role of the stateRaft (paper Figure 2)PMMC acceptorLost after a restart means
guard number an old write is accepted after a newer read
vote or promisepart of two leaders for one number
memory of writesthe node in the intersection forgets the chosen value
commit progressnot persisteddecisions may be persistednothing unsafe: it is recomputed from a quorum

Why does Raft need while a Paxos acceptor does not? A ballot names its leader , so promising ballot already says which leader the promise is for, and at most one proposer ever uses . A Raft term does not name a leader; several candidates may campaign in the same term, and records which one got this server’s vote (Lemma 5.9). Raft could avoid it by making terms pairs (number, candidate id) as Paxos does, at the price of ballots that are no longer consecutive integers.

When to choose which

Both protocols are safe in the same failure model (crash-stop or crash-recovery with stable storage, asynchronous network) and live under the same assumption (partial synchrony, so that a leader eventually stays in place; Theorem 4.16 says some such assumption is needed). The choice is about engineering.

ConsiderationFavors RaftFavors Multi-Paxos
understandabilityone paper, complete pseudocode, one log per servermany variants; PMMC is complete but longer
leader electioncheap votes, no state transferany node can lead at once, e.g. the closest one
holes and parallelismno holes, simple apply loopslots decided out of order, pipelining
quorum flexibilitymajorities throughoutPhase 1 and Phase 2 quorums can differ (3)
follower repairwalk-back, possibly many roundsone Phase 1 collects all slots

Howard and Mortier describe both in the same simplified style and conclude that neither is substantially easier to understand once presented that way, and that Raft’s restrictive election is surprisingly efficient for its simplicity (1). The safer conclusion for this course: learn one in full detail, learn the dictionary, and recognize the other as the same algorithm with a different election rule.

Key point

Raft and Multi-Paxos are the same protocol in two notations, with one real difference: Raft elects only a leader that already holds every committed entry and checks this with a vote, while Paxos elects anyone and makes it read what it is missing from a quorum. Both rest on Lemma 10.5.

What breaks

  • Dropping the up-to-date check in Raft without adding Phase-1 state transfer: a leader without a committed entry overwrites it on its followers (Leader Completeness fails).
  • Dropping pmax in Paxos while keeping “anyone can lead”: the new leader proposes its own command in a slot that was already chosen (C2 fails).
  • Counting replicas under the old number. Raft without the current-term commit rule reproduces Figure 8. Paxos may count because it renumbers adopted values under the new ballot first.
  • Non-intersecting quorums. If , the lemma has no node to point at, and two leaders can commit different values for one position.
  • Losing the guard number. A node that forgets or after a restart can accept an old write after a newer read, and the proof of the lemma fails at its only step.

Why it matters

Every consensus protocol in practice, including ZooKeeper’s Zab in the next part of the course, follows the same pattern: a monotone number, a read quorum that fences off old leaders and learns or checks what was written, and a write quorum per command. Knowing the dictionary and the quorum lemma lets you read a new protocol by asking two questions: how is a leader’s log made complete, and how are old leaders fenced off?

Further reading

  • Howard and Mortier, “Paxos vs Raft: Have We Reached Consensus on Distributed Consensus?” (1): both protocols in one notation; the source of this module’s main claim.
  • Kleppmann, lecture notes, Section 6.1 (2): leaders, terms and the round-trip picture of Slide 110.
  • Ongaro and Ousterhout (4), Section 10 (related work): Raft compared with Paxos, VR and Zab.
  • van Renesse and Altinbuken (5): the PMMC pseudocode used in the dictionary.
  • Howard, Malkhi and Spiegelman, Flexible Paxos (3): quorums that intersect only across phases.
  • Oki and Liskov, Viewstamped Replication (6): a third member of the family, older than both, with views in place of terms.

Homework

The problems for this module are in Homework 10.

1.
Howard H, Mortier R. Paxos vs Raft: Have We Reached Consensus on Distributed Consensus? In: Proceedings of the 7th Workshop on Principles and Practice of Consistency for Distributed Data (PaPoC). 2020.
2.
Kleppmann M. Distributed Systems: Lecture Notes [Internet]. University of Cambridge, Computer Science Tripos Part IB; 2021. Available from: https://www.cl.cam.ac.uk/teaching/2122/ConcDisSys/dist-sys-notes.pdf
3.
Howard H, Malkhi D, Spiegelman A. Flexible Paxos: Quorum Intersection Revisited. In: Proceedings of the 20th International Conference on Principles of Distributed Systems (OPODIS). 2016. p. 25:1-25:14. (LIPIcs; vol. 70).
4.
Ongaro D, Ousterhout J. In Search of an Understandable Consensus Algorithm. In: Proceedings of the USENIX Annual Technical Conference (ATC). 2014. p. 305–19.
5.
van Renesse R, Altinbuken D. Paxos Made Moderately Complex. ACM Computing Surveys. 2015;47(3):42:1-42:36.
6.
Oki BM, Liskov BH. Viewstamped Replication: A New Primary Copy Method to Support Highly-Available Distributed Systems. In: Proceedings of the 7th ACM Symposium on Principles of Distributed Computing (PODC). 1988. p. 8–17.