Bitpath

Lesson 2 · Unit 04

Raft, traced

Elections, the log and what committed means

13 exercisesabout 3 min

What you practise

  • Terms, votes, the replicated log, committed means on a majority, a leader crash and recovery followed step by step

Try a question from this lesson

Pick one

Five nodes. The leader appends a write to its own log and crashes before sending it to anyone. A new leader is elected. Should that write survive?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Raft: roles and terms

Raft is a consensus algorithm built around a replicated log. Every node is a follower, a candidate or the leader.

Time is cut into numbered terms, and each term has at most one leader. The leader sends heartbeats. A follower that hears none for a while starts an election for the next term.

follower  -- timer fires ---> candidate
candidate -- majority votes -> leader
anyone    -- sees higher term -> follower

Concept

The log and commit

Clients send commands to the leader. It appends each one to its log and sends it to the followers.

An entry is committed once a majority of nodes has stored it. Only then does the leader apply it and answer the client.

A committed entry is never lost: any future leader is guaranteed to have it.

index:       1   2   3   4
leader:     [a] [b] [c] [d]
follower 1: [a] [b] [c]
follower 2: [a] [b]

committed: 1 to 3 (on 2 of 3 nodes)

10 more exercises in the app

  • 1× order the lines
  • 3× type the answer
  • 4× multiple choice
  • 1× true or false
  • 1× fill the blanks

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy