Sketch · 2026-11-23
Raft, five servers and a slow network.
Five servers have to agree on one ordered log while any of them can stop answering. Raft does it by electing a leader for a numbered term and letting only the leader append. An entry counts once a majority holds a copy. Everything below runs at a tenth of real speed, so each message is a dot you can follow.
Each cell is a log entry, coloured by the term it was written in. Solid cells are committed on that server. Outlined cells are not yet.
Things to try
Crash the leader. Nothing happens for a while, because the followers only notice through silence. Each one keeps a timer, drawn as the ring around it, that every heartbeat resets. The first ring to run out turns its server into a candidate. It bumps the term and asks the others for a vote. Each server gives one vote per term, so at most one candidate can collect three.
Now drag the timeout jitter to zero and crash the leader again. All four survivors time out together and vote for themselves, so nobody reaches a majority. They wait, time out together again, and repeat. The randomised timeout in the paper exists for this one case, and a spread of a few tens of milliseconds is enough to make it rare. In this simulation nothing else breaks the tie, so the term number climbs for as long as you let it. Raise the jitter again and the next round settles it.
Then press Partition the leader. It and one follower end up on their own side of the dashed line. The old leader carries on believing it is in charge. Switch the click mode to write and send it a few entries: they land in its log and stay outlined, because two copies are not a majority of five. The other three elect a new leader in a higher term and keep committing. Heal the partition and the old leader sees the higher term in the first message it receives, steps down, and has its orphaned entries overwritten.
Two rules carry most of the safety. A server refuses its vote to a candidate whose log is behind its own, judged by the term of the last entry and then by length, so a new leader always holds every committed entry. And a leader only advances the commit index by counting copies of an entry from its own term. Older entries become committed as a side effect. Section 5.4.2 of the paper shows a five-step history where counting old entries directly would commit something that later gets erased.
What is left out: snapshots, membership changes, and the client side of things such as retries and deduplication. Messages here are never lost on a healthy link and never reordered by more than the latency jitter, which is gentler than a real network. Restarted servers keep their term, vote and log, as the paper requires of persistent state, and forget their commit index.
Sources
- Ongaro, D., Ousterhout, J. (2014). In Search of an Understandable Consensus Algorithm. USENIX Annual Technical Conference, pages 305-319. Figure 2 is the whole protocol on one page.
- Ongaro, D. (2014). Consensus: Bridging Theory and Practice. PhD thesis, Stanford University.
- Lamport, L. (1998). The Part-Time Parliament. ACM Transactions on Computer Systems, 16(2), pages 133-169. The Paxos paper Raft was written to be easier than.