The classic consensus algorithm: propose, promise, accept.
Paxos is the classic algorithm that lets a group of machines agree on one value, even when some machines crash and messages are lost or late. It was described by Leslie Lamport.
Paxos solves one problem: get a group to choose a single value and never change its mind. Real systems repeat it many times (Multi-Paxos) to build a log of decisions, but the core idea is this one choice.
Paxos describes three roles. One machine can play all three:
The two phases for a proposal numbered n:
| Message | From โ To | Meaning |
|---|---|---|
| Prepare(n) | Proposer โ Acceptors | Please promise to ignore proposals below n |
| Promise(n, accepted) | Acceptor โ Proposer | Promised. Here is the highest proposal I already accepted (if any) |
| Accept(n, v) | Proposer โ Acceptors | Please accept value v with number n |
| Accepted(n, v) | Acceptor โ Proposer and learners | I accepted it |
| Nack / refuse | Acceptor โ Proposer | I promised a higher number, so I refuse |
| Paxos | Raft | |
|---|---|---|
| Goal | Agree on a value (the log is added by Multi-Paxos) | Replicate a log, with leader election built in |
| Leader | Optional in the basic form, an optimisation in Multi-Paxos | Always, and strongly enforced |
| Easy to learn | Famously hard to turn into a real system | Designed to be understandable |
| Log gaps | Entries can be chosen out of order | The log is always contiguous |
| Used by | Chubby, Spanner, many internal systems | etcd, Consul, CockroachDB, TiKV |
A simplified single-decision Paxos with 3 acceptors and no message delay. Numbers like (1, A) mean proposal number 1 with value A. Real systems run many rounds (Multi-Paxos) and save every promise to disk before replying.
| Term | Meaning in easy words |
|---|---|
| Proposer | A node that suggests a value and drives the two phases |
| Acceptor | A node that promises and accepts. A majority of them decides |
| Learner | A node that learns the chosen value |
| Proposal number (ballot) | A growing number that orders proposals. Higher wins |
| Prepare / Promise | Phase 1: ask for and receive a promise to ignore lower numbers |
| Accept / Accepted | Phase 2: ask for and record acceptance of a value |
| Chosen | A value accepted by a majority. It can never change |
| Quorum | A majority of acceptors. Any two quorums overlap |
| Multi-Paxos | Running Paxos again and again, with a stable leader, to build a log |
| Livelock | Proposers keep blocking each other, so nobody finishes |
| Replicated state machine | Replicas that apply the same ordered commands and so stay identical |
| Choice | We gain | We lose |
|---|---|---|
| Basic Paxos per value | Simple idea, no leader | Two round trips for each value |
| Multi-Paxos with leader | One round trip per entry | Leader failure causes a pause and election |
| Larger cluster | More crashes tolerated | More messages and slower writes |
| Spread across regions | Survives a whole region loss | Cross-region latency on every decision |
| Paxos instead of Raft | More flexibility, many variants | More work, fewer ready-made examples |
| Fast Paxos / EPaxos | Fewer message delays | More complex, needs larger quorums |