Consensus
Paxos, Raft, leader election, membership changes, and production coordination services.
Figure: Raft leader election and replication states.
What You'll Learn
Consensus is how distributed systems agree on a single ordered log despite failures. You will understand the consensus problem, why FLP makes pure async consensus impossible, how Raft and Paxos work, and how etcd, ZooKeeper, and Consul apply these ideas in production.
Chapters
Core Theory
| Chapter | Focus |
|---|---|
| The Consensus Problem | Agreement, validity, termination |
| FLP Impossibility | Why consensus requires failure detectors or timing |
| Paxos | Single-decree and multi-decree Paxos |
| Multi-Paxos | Log-based Paxos, leader optimization |
| Raft Consensus | Leader election, log replication, safety |
| Viewstamped Replication | Alternative formulation of replicated state machines |
Operations and Production
| Chapter | Focus |
|---|---|
| Leader Election | Bully, ring, Raft election details |
| Membership Changes | Joint consensus, safe reconfiguration |
| Distributed Leases | Time-bounded locks with TTL |
| Fencing Tokens | Preventing stale primary writes |
| ZooKeeper Atomic Broadcast (Zab) | ZooKeeper's consensus protocol |
Production Systems
| Chapter | Focus |
|---|---|
| Apache ZooKeeper | Coordination service, znodes, watches |
| etcd | Kubernetes control plane, Raft-backed KV |
| HashiCorp Consul | Service mesh coordination, Raft |
Learning Path
- Consensus Problem and FLP — know the limits before the algorithms.
- Raft — whiteboard this for interviews; then read Paxos for historical depth.
- Leader Election, Membership Changes, Fencing Tokens — production concerns.
- Study etcd or ZooKeeper as a concrete system you have likely operated.
Interview Prep
| Resource | Topic |
|---|---|
| Google Spanner | Paxos groups, TrueTime |
| Lab 003 Raft | Raft simulation on :8098 — engineer guide |
| Lab 004 KV | Quorum replication on :8095 — engineer guide |
| Lab 007 locks | Distributed locks on :8100 — engineer guide |
Prerequisites
- Distributed Systems Foundations
- Replication — helpful context for log replication
Production readiness + Game Day
Every substantive chapter in this domain targets the Production LLD and Game Day Standard: whiteboard Production LLD (APIs, data, failure paths) and run Game Day drills (inject → detect → mitigate → verify → learn).
| Start here | What you practice |
|---|---|
| Chapter §22A / §22B (where present) | Ship-ready LLD + drill catalog |
| Chapter §23 PRACTICE | Full interview script |
| Curriculum Overview — Phase 7 | Rollout status |
Next Domain
Continue to Replication and Transactions.
Return to the Curriculum Overview for the full learning path.