Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 11 · From Scratch · Raft · with code: Go · about 12 min to read

Watch: Consensus: who holds the pen
▶ VideoPlay it as a journeyTutor comes with a plan

Raft 01: Leader Election

Who Holds the Pen
Who Holds the Pen · Open board

The System Design episode on who is allowed to write and what the picking cannot protect. This lesson builds the picking. Part of the Raft series, Build Your Own Raft.

Before you start. This series builds a small copy of Raft, the algorithm a group of machines uses to keep one shared list of commands. This first stage builds only the part that decides which machine is in charge. You need Build Your Own Raft for the map and for what the simulated world looks like (five nodes, a queue for a network, a clock that moves one tick at a time). The idea of one machine holding the pen comes from Who holds the pen (consensus & Raft).

Lesson 78 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 21 October 2018: forty-three seconds
  • Terms, votes, and one rule about majorities
  • The messages and the node
  • The timer and the candidate
  • The handler
  • Run it
  • The tests, and what they pin
  • Break it, twice

Terms it explains: terms, follower, candidate, leader, commit, consensus, election timeout, heartbeat, leader / follower / candidate, log entry, Paxos, quorum / majority, Raft, split-brain fence, term.

Lab

The room splits in two. Both halves think they are in charge. Who is allowed to write?

Stay on Whoever asks first, press Add next write to the end of the night, and watch The bill so far.

Open Who holds the pen

Related papers

Review From Scratch