Agreement Through a Leader
Consensus means a group of nodes agree on a single sequence of values even when some fail. Raft makes this approachable by electing one leader that owns all client writes, so followers never have to reconcile competing proposals.
Terms and Elections
Time is divided into numbered terms. Each term has at most one leader. A node that hears nothing from a leader becomes a candidate, increments the term, and requests votes. A candidate that wins a majority becomes leader. Because each node votes once per term, two leaders cannot both win the same term.
Replicating the Log
The leader appends client commands to its log and sends them to followers.
- An entry is committed once it lives on a majority of nodes.
- Committed entries are then applied to the state machine in log order.
- A new leader must already hold all committed entries, which the voting rules guarantee.
Why a Majority
A majority of any two majorities always overlap on at least one node, so a committed entry survives any election. That overlap is what keeps the log consistent across leader changes.
Key idea
Raft elects one leader per term and commits a log entry only after a majority stores it, so overlapping majorities preserve agreement across failures.