Paxos is a consensus algorithm that lets a group of unreliable servers agree on a single value, or on a sequence of values, even when some servers crash and messages are delayed, lost or reordered. In database replication, Paxos keeps the copies of a replicated log consistent, so every replica applies the same writes in the same order and the cluster behaves like one reliable machine.
Leslie Lamport described the Paxos algorithm in the late 1980s and published it in 1998. It remains the theoretical foundation for many replicated databases and coordination services, and it is the reference against which later protocols such as Raft are measured. Paxos guarantees safety under all conditions and progress whenever a majority of nodes can communicate.
How Paxos reaches agreement
Paxos reaches agreement through two phases of voting in which a proposer must win the support of a majority quorum of acceptors before a value is considered chosen. Because any two majorities share at least one node, a later proposal always learns about an earlier chosen value and cannot overwrite it.
Every attempt carries a unique, increasing proposal number (often called a ballot). In phase 1 (prepare and promise), the proposer asks acceptors to promise that they will ignore any proposal with a lower number. Each acceptor that promises also reports the highest-numbered value it has already accepted. In phase 2 (accept and accepted), the proposer sends a value: if any acceptor reported an earlier accepted value, the proposer must reuse the value with the highest ballot; otherwise it may propose its own.
Each participant can play one or more of three roles. The table below summarizes what each role stores and does.
| Role | Responsibility | Durable state |
|---|---|---|
| Proposer | Starts a ballot and drives both phases | Highest ballot number it has used |
| Acceptor | Votes on proposals and forms quorums | Promised ballot, accepted ballot and value |
| Learner | Discovers which value was chosen | Chosen value or log entry |
Acceptors must write their promises and accepted values to stable storage before replying. If an acceptor forgets a promise after a restart, it can vote twice and break the safety guarantee, which is why correct implementations call fsync or an equivalent on every vote.
Multi-Paxos and the replicated log
Basic Paxos chooses only one value, so databases use Multi-Paxos, which runs a separate Paxos instance for every slot of a replicated log. Each slot holds one command, such as a committed transaction, and replicas apply the slots in order to reach identical states, a pattern known as state machine replication.
Running both phases for every slot would cost two round trips per write. Multi-Paxos therefore elects a stable leader that completes phase 1 once for all future slots and then issues only phase 2 messages. In the normal case a write needs one round trip to a majority, which matches the latency of synchronous replication to a quorum.
The variants below trade complexity for latency, throughput or fault tolerance.
| Variant | Main idea | Typical benefit |
|---|---|---|
| Basic Paxos | Agree on one value with two phases | Simplest proof of correctness |
| Multi-Paxos | Stable leader skips phase 1 per slot | One round trip per committed write |
| Fast Paxos | Clients send directly to acceptors | Fewer message delays without conflicts |
| EPaxos | Leaderless ordering of commands | Lower latency across regions |
| Flexible Paxos | Phase quorums need only to intersect | Smaller replication quorums |
| Cheap Paxos | Auxiliary nodes join only on failure | Fewer full replicas to operate |
Paxos compared with Raft and other replication methods
Paxos differs from simpler replication schemes because it tolerates leader failure without split-brain and without manual intervention. Primary-replica replication with asynchronous shipping can lose acknowledged writes during failover, while Paxos never loses a value once a majority has accepted it.
Raft solves the same problem as Multi-Paxos but fixes many design choices that Paxos leaves open, such as leader election rules and how logs are repaired. Many engineers find Raft easier to implement, although the two are closely related in their safety arguments.
| Approach | Failover behavior | Main limitation |
|---|---|---|
| Multi-Paxos | Automatic, quorum-based | Many unspecified implementation details |
| Raft | Automatic, strong leader | Leader is a throughput bottleneck |
| Asynchronous replication | Manual or scripted promotion | Possible loss of recent writes |
| Two-phase commit | Blocks if the coordinator fails | Not fault tolerant on its own |
Paxos and two-phase commit are often confused. Two-phase commit makes several shards agree to commit one transaction, whereas Paxos replicates state within a group; systems such as Google Spanner combine both, running two-phase commit across Paxos groups.
Sizing and operating a Paxos cluster
A Paxos group of 2f + 1 nodes tolerates f failures, because the surviving nodes must still form a majority. Operators therefore deploy odd-sized groups, usually three or five replicas, and place them in separate failure domains.
| Replicas | Quorum size | Failures tolerated |
|---|---|---|
| 3 nodes | 2 | 1 |
| 5 nodes | 3 | 2 |
| 7 nodes | 4 | 3 |
Larger groups improve availability but increase write latency, because the leader must wait for more acknowledgments and the slowest member of the quorum sets the pace. In geo-replication, a five-node group across three regions keeps working through a full region outage while commit latency follows the round-trip time to the second-nearest region.
Limitations and common implementation mistakes
Paxos guarantees safety but not guaranteed progress. The FLP impossibility result shows that no deterministic algorithm can guarantee consensus in a fully asynchronous network with even one faulty process, so competing proposers can keep preempting each other in a livelock. Implementations use leader election with randomized timeouts to restore progress in practice.
- Skipping durable writes on acceptors, which allows double voting after a crash.
- Reusing proposal numbers across nodes instead of embedding a node identifier in each ballot.
- Serving reads from the leader without a lease or quorum check, which can return stale data after a partition.
- Ignoring log compaction, so snapshots and truncation are missing and the log grows without limit.
- Changing membership unsafely, for example adding several nodes at once without a reconfiguration protocol.
The original papers specify the core agreement step but leave out snapshots, membership changes and client retries. Production teams have repeatedly reported that bridging this gap is where most of the engineering effort and most of the bugs appear.
Stripped to the essentials
Imagine five people who must agree on a meeting date. They can only pass notes. Some notes get lost, and anyone might leave the room. Paxos is a set of rules that stops them from writing down two different dates. It works as long as more than half of them can still pass notes.
A database uses the same rules to keep several copies of its data identical. Each change counts only after a majority agrees. One broken server cannot cause confusion or lose a confirmed change.
Where it is applied
A payments company runs its account ledger on a distributed SQL database with five replicas spread across three data centers. Every balance update becomes an entry in a Paxos-replicated log, and the leader confirms the write to the application only after three of the five replicas have stored it on disk.
One afternoon a power failure takes down an entire data center that hosts two replicas, including the current leader. The remaining three replicas still form a majority, so within a few seconds one of them wins a new ballot, completes phase 1 and continues the log from the last chosen entry. No confirmed payment is lost, and the application sees only a brief rise in latency instead of an outage or a manual failover.