Home About Me

Paxos: A Practical Look at Distributed Consensus

Paxos is a consensus algorithm for distributed systems, introduced by Leslie Lamport in 1990. It addresses a deceptively simple question: in an environment where nodes may fail and messages may be delayed, how can multiple nodes agree on a single value? The protocol does not eliminate failures or latency, but it gives nodes a disciplined way to reach agreement without contradicting one another.

Roles and basic terms

Paxos divides work among three roles.

  • Proposer: puts forward a proposal. In practice, a node that needs the system to settle on a value acts as a proposer.
  • Acceptor: receives proposals and decides whether to accept them. Acceptors are the voters in the protocol.
  • Learner: does not propose or vote. It learns from acceptors which proposal has been chosen and thereby obtains the agreed value.

A proposal consists of two parts: a proposal number and a proposal value. The number is globally unique and ordered; the value is the item on which the system needs consensus. A proposal is considered chosen once more than half of the acceptors have accepted it. At that point, the distributed system has settled on that proposal's value.

The prepare phase

  1. A proposer selects a proposal number, call it n, and sends a prepare request containing n to all acceptors.
  2. When an acceptor receives the prepare request, it checks n against the proposal numbers it has already responded to. If n is greater than all such numbers, the acceptor promises not to accept any proposal numbered lower than n. It also returns the highest-numbered proposal it has already accepted, if there is one. If n is not greater than the highest number it has already seen, the acceptor may ignore the request.

The accept phase

  1. If the proposer receives responses from a majority of acceptors, it uses those responses to decide what value to propose. If any response contains an already accepted proposal, the proposer adopts the value of the highest-numbered proposal among them. If none does, the proposer may choose its own value, v. It then sends an accept request for (n, v) to all acceptors.
  2. An acceptor that receives the accept request accepts (n, v) if it has not already accepted a proposal with a higher number and the request is consistent with the promise it made during the prepare phase. Otherwise, it may ignore the request.
  3. Once a majority of acceptors accept (n, v), the proposal is chosen. Learners can then discover the chosen value from the acceptors.

Safety and liveness

Paxos is organized around two kinds of guarantees. Safety means that only a proposal that has actually been put forward can be chosen; at most one value can be chosen; and once a node learns that a value has been chosen, it cannot later treat a different value as chosen. Liveness means that, under the protocol's assumptions, some proposal will eventually be chosen and learners will eventually learn it.

Strengths and costs

Paxos has strong fault tolerance. It can continue to reach consensus as long as a majority of acceptors are working, even if some nodes fail. Its theoretical foundation is also unusually solid: it was the first consensus algorithm rigorously proved to work correctly in a distributed environment, and it became a foundation for later work on distributed consensus.

The costs are equally important. The original protocol is difficult to describe and implement, especially when multiple proposals are competing or when failed nodes need to recover. It also requires multiple message exchanges across the prepare and accept phases, so high network latency can reduce its efficiency.

Where Paxos appears

Paxos has been used in distributed databases, distributed file systems, and distributed lock services. Google's Chubby lock service, for example, uses a variant of Paxos so that nodes can agree on the state of a lock. Its influence extends beyond any single deployment: for systems that need agreement in the presence of failure, Paxos remains a reference point for how careful protocol design can turn an unreliable network into a reliable shared decision.