Leader Election (Raft)
Software Engineer path · lesson 80 of 99Visualize how distributed databases elect a Leader and recover from crashes using the Raft Consensus Algorithm.
Elect a leader
Order a Raft leader election.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
- 1Drop a step here
- 2Drop a step here
- 3Drop a step here
- 4Drop a step here
- 5Drop a step here
Test your knowledge
What is the purpose of the Leader continuously sending empty messages (Heartbeats) to all Followers in the Raft algorithm?
The short version
Raft is like a classroom. The Teacher (Leader) constantly talks (Heartbeats) so the students (Followers) know she is there. If the Teacher leaves the room and stops talking, eventually a student will stand up (Candidate), ask the class if they can be the new Teacher, and if they get enough votes, they take over the class.
In more depth
Raft Consensus Algorithm
In a distributed database, nodes must agree on the state of the data (Consensus). To do this efficiently, most systems elect a single Leader to handle all writes and replicate them to Followers.
The Election Process
Interview Questions
References & Further Reading
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required