Stackbook Logo
coordinationestablished · high operational burden

Paxos Overview

Also known as: paxos, multi-paxos

Intent

Reach agreement on a single value among unreliable nodes using proposers, acceptors and quorums.

Problem

Distributed nodes must decide on one value despite crashes, message loss and competing proposers. Without a safe protocol, two groups can decide different values. Practical systems also need to agree on a sequence of values, not just one.

Forces

  • •Safety must never be violated even if liveness is lost
  • •Concurrent proposers can livelock each other
  • •Single-decree agreement is not enough for a replicated log
  • •Protocol is notoriously hard to implement correctly

Solution

Overview

Paxos is the original family of consensus protocols. Basic Paxos decides one value; Multi-Paxos chains many decisions into a replicated log. Most modern consensus systems are Paxos relatives, and Raft was designed as a more approachable alternative.

How it works

Three roles exist, often colocated on each node: proposers, acceptors and learners. Each proposal has a unique, increasing number n.

Phase 1  Proposer -> Acceptors: prepare(n)
         Acceptor: if n > promised then promised=n,
                   reply promise(acceptedN, acceptedV)
Phase 2  Proposer -> Acceptors: accept(n, v)
         v = value with highest acceptedN seen, else own value
         Acceptor: if n >= promised then accept
Chosen when a majority accepted the same (n, v)

The key safety rule is that a proposer must adopt any value a majority might already have accepted. Two majorities always overlap in at least one acceptor, so that acceptor carries the earlier decision forward. Multi-Paxos lets a distinguished leader run phase 1 once and then issue only phase 2 messages for each log slot.

Pitfalls

  • Acceptors must persist promised and accepted state durably before replying.
  • Without a distinguished proposer, rivals keep preempting each other and no value is chosen.
  • Gaps in the log need no-op filling after leader change.
  • Reconfiguration is outside basic Paxos and easy to get wrong.
  • Implementing from papers alone usually yields bugs; prefer a tested library or TLA+ model checking.

Key takeaways

  • Paxos guarantees safety always and liveness only with a stable leader.
  • Quorum intersection is the core idea behind its correctness.
  • Prefer Raft or a vetted library unless you need Paxos-specific variants.

✓ When to Use

  • •Understanding the theory behind consensus systems
  • •Systems already built on Paxos variants such as Spanner or Chubby
  • •Needing a flexible foundation for custom replicated state machines

✗ When Not to Use

  • •Greenfield projects where Raft libraries suffice
  • •Teams without experience in distributed protocol verification
  • •Data that does not need strong agreement

Pros

  • +Proven safety under asynchrony and crashes
  • +Tolerates minority failures without blocking
  • +Many optimized variants such as Fast Paxos and EPaxos

Cons

  • −Specification leaves many practical details open
  • −Hard to implement and debug
  • −Dueling proposers can stall progress

Cost Profile

Infrastructure

3 or 5 acceptor replicas

Operational

High: custom implementations and tooling

Cognitive

High: subtle invariants and variants

Failure Modes

  • Dueling proposers livelock without a stable leader

  • Acceptor state not persisted before reply breaks safety

  • Incorrect quorum configuration lets two values be chosen

Real-World Examples

Alternatives

    Related Patterns

    • leader-election
    • replication

    Competency Domains

    distribution communicationdata state