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 05 · System Design · Deeper than the interview · about 17 min to read

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

How you know it holds: Jepsen, simulation and models

Who Holds the Pen
Who Holds the Pen · Open board

The group that must agree on who holds the pen. This lesson asks how you would ever know that such a group, or any copy-and-failover design, keeps its promise on the worst day.

Before you start. You need The log is the truth (event sourcing and CQRS): a log of events is the truth, and the state is what you get by replaying it. You need The copy clerks (database replication): one primary takes the writes and a backup copies them a moment later. You need What did the database promise? (consistency models): a write the database says it kept is acknowledged, and losing one is the worst failure. And Who holds the pen (consensus & Raft) showed how a majority picks one writer. Here we do not design anything new. We test a design.

Lesson 37 of 115 in System Design

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

  • The test that passes, and the bug that stays
  • The design under test, as a few lines
  • Fault injection: break it on purpose, many times
  • Simulation: same seed, same run, every time
  • A history check: judge only what clients saw
  • Model checking: look at every state, not a sample

Terms it explains: acknowledged, primary, backup, failover, buggy, safe, invariant, Fault injection, deterministic, seed, deterministic simulation testing, history, model checker, Common mistakes, 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 System Design