Skip to the content.

Paxos Consensus Algorithm

Overview

The Paxos algorithm is a fundamental consensus protocol used in distributed systems to ensure that multiple nodes agree on a single value, even in the presence of failures or network partitions.
It is widely used in distributed databases, coordination services (e.g., Chubby, Zookeeper), and fault-tolerant systems.


1. Key Concepts

Term Description
Consensus Agreement among distributed nodes on a single value.
Proposer Node that proposes a value for agreement.
Acceptor Node that decides whether to accept a proposed value.
Learner Node that learns the final agreed value.
Quorum Minimum number of nodes that must agree to make a decision (typically >50%).

2. Problem Paxos Solves


3. Roles in Paxos

  1. Proposer
    • Suggests a value to be chosen.
    • Coordinates the consensus process.
  2. Acceptor
    • Votes to accept or reject proposed values.
    • Maintains the highest proposal number seen to ensure consistency.
  3. Learner
    • Learns the value once a quorum of acceptors agrees.
    • Can be the proposer itself or separate nodes.

4. Basic Paxos Protocol Steps

Step 1: Prepare

Step 2: Accept

Step 3: Learn


5. Paxos Example

Scenario: Three nodes A, B, C want to agree on a value.

  1. Proposer A proposes X with proposal number 1.
  2. Sends Prepare(1) to B and C.
  3. B and C promise not to accept lower numbers; no previous values.
  4. A sends Accept(1, X).
  5. B and C accept X.
  6. Quorum reached → X is chosen.

Key Rule: If multiple proposers exist, proposal numbers ensure no conflicting decisions.


6. Multi-Paxos

Optimization:


7. Guarantees

Guarantee Explanation
Safety No two nodes decide differently on the same instance.
Liveness Eventually, some value is chosen if a majority of nodes are operational.
Fault Tolerance Can tolerate up to f failures in 2f+1 nodes.

8. Challenges


9. Variants / Alternatives


10. Summary


References