Why Raft exists
Raft, by Ongaro and Ousterhout, was built to be understandable where Paxos is opaque. It solves the same problem, a replicated log, by leaning on a single strong leader.
Three subproblems
Raft decomposes consensus cleanly:
- Leader election nodes vote for a leader within a numbered term
- Log replication the leader appends entries and pushes them to followers
- Safety rules ensure committed entries are never lost
How election works
Time is divided into terms. A follower that hears no heartbeat becomes a candidate, increments the term, and requests votes. A node grants at most one vote per term, so a majority elects exactly one leader. Randomized election timeouts make split votes rare.
How replication works
- The leader receives a command and appends it to its log
- It sends append entries to followers
- Once a majority store the entry it is committed and applied
Safety guarantees
A candidate can only win if its log is at least as up to date as the majority, so a new leader always has every committed entry. This is the election restriction that keeps the log consistent.
Key idea
Raft splits consensus into leader election log replication and safety, using terms and randomized timeouts to elect one leader whose log carries every committed entry.