Consensus: Raft
Lesson, slides, and applied problem sets.
View SlidesLesson
Consensus: Raft
Why consensus
Replication without agreement leads to divergence. Consensus ensures a single, consistent log despite failures.
Raft at a glance
Raft splits the problem into three parts:
- Leader election
- Log replication
- Safety
Elections
A follower grants a vote if:
- Candidate term is up-to-date
- Candidate's log is at least as up-to-date
- Follower hasn't voted for someone else in this term
What you will build
- Vote granting logic
- AppendEntries conflict handling
- Full AppendEntries (term-by-term)
- Commit index calculation
- Conflict backtracking optimization
- Snapshot log compaction
- Joint consensus commit index
- Election timeout scheduling
Module Items
Raft Vote Grant
Raft AppendEntries
Raft AppendEntries (Full)
Raft Commit Index
Raft Conflict Backtracking
Raft Snapshot Compaction
Raft Election Timeouts
Raft Joint Consensus Commit
Raft Milestone: Follower RPC Handling