Paxos Algorithm
Paxos Algorithm
Introduction: The Greek Senate
In the 1980s, Leslie Lamport imagined a fictional legislative system on the Greek island of Paxos. The legislators (nodes) were often absent or inconsistent, yet they needed to pass laws (reach consensus).
Paxos is the first mathematically proven solution to the problem of reaching consensus in a network of unreliable processors. It is famously difficult to understand, yet it is the foundation upon which almost all modern distributed systems (like Google’s Spanner) are built.
What Problem does it solve?
- Input: Multiple nodes proposing different values.
- Output: All nodes agree on a single value.
- The Promise: Safety (only a proposed value is chosen) and Liveness (a value is eventually chosen).
Core Idea (Intuition)
Paxos works via a Three-Phase Protocol:
- Prepare: A Proposer sends a proposal with a unique number () to a majority of Acceptors.
- Promise: If the number is the highest an Acceptor has seen, it promises never to accept a lower-numbered proposal.
- Accept: Once the Proposer gets enough promises, it asks the Acceptors to officially “accept” the value.
It’s like an Auction: You can’t win unless your bid number is higher than everyone else’s, and once the majority agrees, the deal is sealed.
How it Works (Multi-Paxos)
Original Paxos only picks one value. To build a real system (like a database), we use Multi-Paxos:
- The nodes agree on a “Leader” (Proposer).
- The Leader can then skip the “Prepare” phase for subsequent values, making it as fast as Raft.
Typical Business Scenarios
✅ High-End Distributed Storage: Google’s Chubby and Spanner are the most famous implementations of Paxos.
✅ Database Kernels: Microsoft SQL Server and Oracle use Paxos variants for their internal replication.
✅ Foundation of Protocols: If you are designing a new distributed protocol, you must prove it is “Paxos-equivalent.”
❌ Developer Implementation: You should never try to implement Paxos from scratch for a production app unless you are a distributed systems researcher. Use Raft or a pre-built library like Zookeeper.
Performance & Complexity
- Complexity: Extremely high. “There is only one consensus algorithm, and that is Paxos. All other consensus algorithms are a special case of Paxos.”
- Efficiency: Similar to Raft in its “Multi-Paxos” form.
Summary
“Paxos is the ‘Godfather’ of distributed systems. It provides the mathematical proof that consensus is possible, even if it takes a PhD to explain exactly how.”
