Consensus Algorithms: A Visual Guide
How to Read This Post Each scenario shows a diagram first, then a short note on why the pattern matters. Complexity increases as you scroll. Algorithm Approach Strength Trade-off Raft Leader-based Understandable, widely adopted Leader bottleneck Paxos Proposer-based Formally proven, flexible Notoriously hard to implement Multi-Paxos Optimized Paxos Fewer round-trips with stable leader Complex recovery ZAB Leader-based Ordered broadcast (ZooKeeper) Tightly coupled to ZK Level 1 — Why Consensus? 1. The Agreement Problem %%{init: {'theme':'dark', 'themeVariables': {'primaryTextColor':'#e5e7eb','secondaryTextColor':'#e5e7eb','tertiaryTextColor':'#e5e7eb','textColor':'#e5e7eb','nodeTextColor':'#e5e7eb','edgeLabelText':'#e5e7eb','clusterTextColor':'#e5e7eb','actorTextColor':'#e5e7eb'}}}%% flowchart TB C[Client] -->|"SET x=5"| N1["Node Ax = 5 ✓"] C -->|"SET x=5"| N2["Node Bx = 5 ✓"] C -->|"SET x=5"| N3["Node C⚡ crashed"] N1 -->|"what is x?"| Q{{"Do all nodesagree x=5?"}} N2 -->|"what is x?"| Q N3 -->|"???"| Q Q -->|"With consensus"| YES["All agree on x=5even with failures"] Q -->|"Without consensus"| NO["Inconsistent statesplit brain possible"] style C fill:#4a9eff,stroke:#2d7ed8,color:#fff style N1 fill:#51cf66,stroke:#37b24d,color:#fff style N2 fill:#51cf66,stroke:#37b24d,color:#fff style N3 fill:#ff6b6b,stroke:#d44,color:#fff style Q fill:#ffd43b,stroke:#f59f00,color:#333 style YES fill:#51cf66,stroke:#37b24d,color:#fff style NO fill:#ff6b6b,stroke:#d44,color:#fff The core problem. Distributed nodes must agree on a single value even when some nodes crash or messages are delayed. Without consensus, you get split-brain — two parts of the system believing different things. ...