TL;DR
Lamport's paper explains Paxos in plain terms. Several servers must agree on one value, even though any of them can stop, restart, or receive messages late or not at all. The core is a consensus protocol with two phases. A proposer first asks a majority of acceptors for a promise not to accept older proposals, and it must reuse the value of the highest-numbered proposal that those acceptors report as accepted. Then it asks them to accept its proposal. Because any two majorities share an acceptor, a chosen value cannot be overturned. The paper then runs the same protocol once per log slot, so the servers agree on the same sequence of commands, which is the basis of a replicated state machine.
Builds on: State Machine Replication, Distributed Consensus, Quorum · Leads to: the practical Paxos variants used in replicated services, and later designs such as Raft, which aim at the same goal with a simpler structure
Why it mattered
Paxos is the reference protocol for consensus in replicated systems. Large storage and coordination services use variants of it to keep a small group of machines in agreement, so that a single failure does not lose or fork the shared state. The paper is a widely cited account of how to build it, because it starts from the requirements instead of from the protocol.
The paper explains the algorithm for readers who could not follow the earlier presentation, which Lamport describes as "Greek to many readers." It also connects consensus to the state-machine approach. A deterministic service replicated on several machines gives the same outputs if every machine runs the same commands in the same order. Paxos supplies that order. The paper's claim is that, once a leader is in place, the cost of a command is the cost of phase 2 alone.
The problem
The paper begins with a set of agents: proposers, acceptors, and learners. A consensus algorithm must satisfy three safety rules. Only a value that some proposer proposed may be chosen. Only a single value may be chosen. A process may learn that a value was chosen only if it actually was.
The model is asynchronous and non-Byzantine. Agents run at arbitrary speed, can stop and restart, and keep their state only if they store it. Messages may take arbitrarily long, be duplicated, or be lost, but they are not corrupted. Liveness is not specified precisely; the goal is that some value is eventually chosen when one is proposed.
Two difficulties follow. First, if only one acceptor exists, its failure stops all progress, so there must be several acceptors. Second, several proposers can propose different values at about the same time, and each value can be accepted by part of the group without any one value winning a majority. The rest of the paper is the answer to that second difficulty.
How it works
The algorithm has two phases. Phase 1 is a promise, and phase 2 is an acceptance. Proposals carry numbers, and numbers are unique and ordered.
sequenceDiagram participant P as Proposer participant A as Acceptor A participant B as Acceptor B participant C as Acceptor C P->>A: prepare(1) P->>B: prepare(1) A-->>P: promise(1), nothing accepted yet B-->>P: promise(1), nothing accepted yet P->>A: accept(1, x) P->>B: accept(1, x) Note over A,B: x is accepted by a majority, so it is chosen P->>B: prepare(2) P->>C: prepare(2) B-->>P: promise(2), accepted (1, x) C-->>P: promise(2), nothing accepted Note over P: highest accepted value reported is x, so value x must be reused
Take three acceptors A, B, and C. A majority is any two of them. Two proposers take part, one with number 1 and one with number 2.
- Prepare. Proposer P sends
prepare(1)to A and B. Each acceptor promises never again to accept a proposal numbered below 1. Neither has accepted anything, so each reports nothing. P has responses from two of three acceptors, a majority. - Free choice of value. Because the responses report no earlier accepted value, P may propose any value. It picks x.
- Accept. P sends
accept(1, x)to A and B. Each accepts, because it has promised nothing higher than 1. Two of three have accepted (1, x), so x is chosen. - Second proposer prepares. Proposer Q sends
prepare(2)to B and C. B has promised only 1 so far, so it promises 2 and reports that it accepted (1, x). C has accepted nothing and promises 2. - Forced value. Q has a majority of responses, so it may propose a value, but the highest-numbered accepted value among the responses is x. Q must propose x. Q's accept request is therefore
accept(2, x), not a value of its own. Even if Q had wanted y, the rule keeps the chosen value unchanged. - Check the safety. Had Q been able to choose y, it would have needed a majority that never heard of x. Any majority of three contains at least one acceptor that accepted x, so Q always learns about x.
The paper also describes the acceptor's optimization. An acceptor needs to remember only two things: the highest proposal number it has promised, and the highest-numbered proposal it has accepted. It answers a prepare only if the number is higher than its promise, and it ignores an accept request whose number is below its promise. These records must survive restarts, so the acceptor writes them to stable storage before it replies.
Learning the chosen value is a separate step. The paper offers two options, and a generalization to a larger set of distinguished learners. Each acceptor can tell every learner, which costs one message per acceptor and learner pair. Or the acceptors can tell one distinguished learner, which costs fewer messages but adds a round and a single point of failure. The paper notes that a value can be chosen with no learner finding out, and then the learner can learn it only when a later proposal is chosen.
The second part of the paper turns this into a log. Each slot of the log is a separate instance of the consensus algorithm, and slot i holds the i-th command. A single leader acts as the only proposer for normal operation, so most commands skip phase 1, as the next section explains.
Here is the scenario from the paper. The new leader knows the chosen commands 1 through 134, plus 138 and 139. It runs phase 1 for slots 135 to 137 and for every slot above 139. The responses decide that slots 135 and 140 must carry values that were already accepted, so it runs phase 2 for those two. Commands 135 and 140 are chosen. Slots 136 and 137 are still empty, so the leader fills them with no-op commands. Once they are chosen, commands 138 to 140 can run. The leader has finished phase 1 for everything above 140, so it can propose new client commands at 141, 142, and so on without another prepare.
The math
Notation: a proposal is a pair (n, v) of a number and a value. The acceptor's state is a promised number p and an accepted pair (n_a, v_a), starting empty.
Majorities always overlap
Let N be the number of acceptors. A majority has at least members. Take two majorities S and C. Their union has at most N members, so their intersection satisfies
The last step holds for both odd and even N. This is the fact behind the phrase in the paper, "any two majorities have at least one acceptor in common." It is why a value accepted by one majority is visible to any later majority.
Phase 1: prepare and promise
A proposer picks a fresh number n and sends prepare(n) to a set of acceptors. An acceptor responds, and only then does it record the promise, if n is greater than its promise p:
The reply reports the accepted pair (n_a, v_a) if there is one. Because of the optimization, a prepare with n no larger than p gets no reply, which is safe because the acceptor will not accept n anyway.
Phase 2: accept
Once the proposer has promises from a majority, it picks a value. If any response reports an accepted pair, it takes the value from the response with the highest accepted number. If none does, it may choose any value. Call the chosen value . The accept request is accept(n, ), and an acceptor accepts it unless it has promised a number greater than n:
The rule for is the step in the walkthrough: the proposer must reuse the value that could already have been chosen. The invariant the paper derives is that if a value v has been chosen with number m, every proposal numbered above m has value v. Phase 1 is the mechanism that keeps this true, because a majority of promises forces the proposer to learn about any value a majority may have accepted.
Why the acceptor writes to stable storage
Suppose an acceptor promises 2 and then restarts without remembering it. It could then accept a proposal numbered 1 that a proposer issued before the promise. That would break the invariant, so the promise and the accepted pair must survive restarts. In the paper's words, an acceptor "must remember this information even if it fails and then restarts."
Unique numbers
Different proposers draw numbers from disjoint sets, and each proposer remembers the highest number it has used, in stable storage, so that its next proposal number is higher. Two proposers can then never issue the same number.
Results
The paper contains no experiments. Its results are arguments and a set of claims about what the protocol guarantees.
- Safety holds whatever the timing. Only a single value is chosen, and only proposed values are chosen, regardless of failures, delays, or how many proposers are active. The paper says safety is ensured "regardless of the success or failure of the election" of a leader.
- Liveness needs a single leader. Two proposers that keep preempting each other can prevent any proposal from being chosen, as the paper's progress example shows. A distinguished proposer that can reach a majority and uses a higher number than any used before will succeed.
- Choosing that leader needs time or randomness. The paper cites the Fischer, Lynch, and Paterson result, which implies that a reliable leader election must use either randomness or real time, for example timeouts. The paper treats that as the price of liveness, not of safety.
- Phase 2 is the steady-state cost. Once one leader holds phase 1 for all future slots, each command costs one phase 2 round. The paper states that this phase has the minimum possible cost of any fault-tolerant agreement algorithm, citing Keidar and Rajsbaum's tutorial, and concludes that Paxos is essentially optimal.
- Phase 1 can be batched. The leader sends one short message to cover infinitely many slots, because an acceptor answers with more than a plain OK only for slots where it has already seen a phase 2 message.
- Gaps are bounded. If the leader can run up to commands ahead, a gap of at most commands can form after a leader failure.
- Membership can change. The set of servers can be part of the state, changed by ordinary commands, and the set for slot is read from the state after command .
The limits are as clear in the paper as its claims. The model excludes Byzantine faults, so a server that lies is outside the guarantee. The leader is a single point of progress, and the paper does not measure the cost of leader election. The implementation section sketches the mechanisms but does not give a full design for stable storage or message formats. Later systems built on the paper have to make those choices themselves, and that work is where most of the difficulty lies in practice.
Reading guide
Read the paper in this order, with the lessons that cover each part.
- Section 1, Introduction. The consensus algorithm and the state-machine approach. The paper cites Lamport's 1978 article on time and ordering, which it calls probably the most often-cited article on the theory of distributed systems: Distributed Consensus, State Machine Replication, Logical Clock.
- Section 2.1, The problem. The safety rules and the asynchronous, non-Byzantine model: Distributed Consensus, Byzantine Fault Tolerance for the model it excludes.
- Section 2.2, Choosing a value. Majorities, P1 and P2, and the invariants that lead to the two-phase algorithm: Quorum, Paxos.
- Section 2.3, Learning a chosen value. The cost of learners and the distinguished learner trade-off.
- Section 2.4, Progress. The livelock example and the role of a distinguished proposer, which needs Leader Election. The FLP result is in Impossibility of distributed consensus with one faulty process.
- Section 2.5, The implementation. Stable storage and disjoint proposal numbers.
- Section 3, Implementing a state machine. Slots, the leader, no-op filling, batched phase 1, and reconfiguration. Compare with Primary-Backup Replication and Linearizability, the guarantee clients care about.
Check yourself
QuestionWhy must any two majorities of acceptors share at least one acceptor, and what does the paper use that fact for?Show answer
QuestionFive acceptors receive prepare(7). Three respond: one reports an accepted pair (5, a), one reports nothing, and one reports (6, b). Which value must the proposer put in accept(7, ·)?Show answer
QuestionWhy must an acceptor store its promise and its accepted pair on stable storage before replying?Show answer
QuestionIn a replicated log, two servers both believe they are the leader. What happens to safety and to progress?Show answer
Sources
- Lamport, Paxos made simple (2001).
- Fischer, Lynch, and Paterson, Impossibility of distributed consensus with one faulty process (1985), the result the paper cites for the need for randomness or timeouts in leader election.
- Lamport, Time, clocks, and the ordering of events in a distributed system (1978).
- Paxos (computer science) (Wikipedia).