Related book
Designing Data‑Intensive Applications
The chapter on consensus and replication is a must-read for understanding Paxos/Raft.
Consensus is a way to agree on a single meaning in a distributed system despite failures, delays and network divisions. Without consensus, you cannot reliably elect a leader, synchronize metadata, or provide linear writes to a quorum cluster.
Foundation
TCP protocol
Consensus relies on network rounds and stable transport.
Where is consensus needed?
Leader selection
Cluster coordination and coordinator/primary assignment.
Metadata
Configurations, membership, data schema and routing.
Consistent entry
Linearizable operations during replication.
Paxos
Paxos is a classic Lamport algorithm. It guarantees the selection of a single value through a two-phase protocol and quorum acceptors. In real systems, Multi-Paxos with a dedicated leader is often used.
Interactive Paxos diagram
Select a step to highlight active participants and messages.
Multi‑Paxos
Paxos optimization for command flow: the leader takes on the Prepare phase once, and then only performs the Accept round for each entry.
What does it give
- Fewer network rounds per entry
- Higher throughput
- The Leader Makes Progress Easy in Conflicts
Multi‑Paxos operation modes
Select a phase to see how the message flow changes.
Each new log entry uses only the Accept round, reducing RTT.
Raft
Raft was designed to be a "understandable consensus". It divides the task into leader election, log replication, and membership management. This makes the protocol easier to explain and implement.
Raft node states
Switch state to see how node role and message flow change.
Accepts client commands and replicates them to followers.
Paxos vs Raft
Paxos
- More difficult to understand and implement
- More formal and "academic"
- Often hidden behind Multi‑Paxos
Raft
- Easier to explain to the team and support
- Explicit leader-centered model
- Used in etcd, Consul, CockroachDB
Key Findings
- Consensus is needed for consistent value selection in the face of disruption.
- Paxos is fundamental but complex; Raft is engineering friendly.
- Both protocols require a majority quorum and are tolerant of partial failures.
Related book
Distributed Systems: Principles and Paradigms
A classic work on consensus and distributed algorithms.
Further on topic
Jepsen and consistency models
How consistency guarantees are tested and where consensus fits into them.
Examples in systems
etcd/Consul (Raft), ZooKeeper (Zab), Cassandra (Paxos for LWT).
Consensus makes the system more reliable, but increases latency and complexity. Use it only where strict consistency is truly needed.
