AdvancedAbout 20 min

    Leader Election (Raft)

    Read the full article on Substack

    7 min read.

    Visualize how distributed databases elect a Leader and recover from crashes using the Raft Consensus Algorithm.

    Think of it this way: 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.

    AfollowerBfollowerCfollowerTerm 0
    Every node starts as a follower and waits to hear from a leader.

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Elect a leader

    Sequence

    Order a Raft leader election.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Quiz

    21 questions
    Question 1 of 21
    Score: 0

    What is the purpose of the Leader continuously sending empty messages (Heartbeats) to all Followers in the Raft algorithm?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going