Unit 14 of 14 · about 4 hours · measure

Election, commit, recovery, message and snapshot costs and availability versus safety diagnosis

A slow consensus group can be waiting safely for a quorum or repeatedly losing leadership. A fast one can still acknowledge unsafe work. Diagnose correctness first, then attribute the costs.

You'll be able to

  • Measure election, commit, application and recovery intervals with explicit event boundaries.
  • Attribute protocol messages, encoded bytes and snapshot creation, transfer and replay costs.
  • Diagnose lost progress separately from violated safety using histories and invariant evidence.
  • Compare matched fault regimes without turning local timings into universal targets.

Covers

Election, commit and recovery latency measurementMessage and snapshot cost measurementAvailability versus safety diagnosis
1

Read

In this order, only the parts listed

0 of 3 done

  1. Raft extended paper: progress and cost mechanismsIn Search of an Understandable Consensus Algorithm

    Section 5.6, Timing and availability; Section 7 final two snapshot-performance issues; Section 9.3, Performance, and Figure 16

    Extract the measurement boundaries and workload setup, not the paper's millisecond values as targets.

  2. MIT 6.5840 Spring 2026 Lab 3: cost sanity checksMIT 6.5840 - Lab 3 Raft

    Part 3A explanation of Passed-line counters; Part 3B TestRPCBytes3B and TestCount3B

    Use the public counters as bounded sanity checks. Inspect the test code before assigning meanings to totals; printed reference timings are not targets for your machine.

  3. Replicated Log and Stream Processor: consensus measurementsReplicated Log and Stream Processor - Consensus Slice

    Milestones B, D and E; Correctness requirements; Measurement requirements

    Measure only the consensus log and snapshot slice here, not the later stream-processing pipeline.

2

Focus on

  • Define failure-to-election, request-to-commit, commit-to-apply, request-to-reply and restart-to-catch-up separately. Logical ticks describe simulated ordering; wall-clock time measures the local implementation.
  • An established five-voter leader needs itself and two followers for a majority. The critical acknowledgements depend on persistence and network scheduling, not automatically the slowest follower or just one network round trip.
  • Count requests and responses separately from client messages, heartbeats, retries and commit notifications. Report encoded bytes as well as counts; snapshot creation, installation, transferred bytes and tail replay are distinct costs.
  • Use matched workload, command size, concurrency, voter count, durability mode, snapshot threshold and fault schedule. Record versions, seeds, repeated-run spread, offered work, successful work and timeouts; preserve raw histories and monitor verdicts.
Common mistakes · 3
  • Reporting only successful-operation latency during a partition while omitting blocked or timed-out requests from the availability denominator.
  • Reducing election timeouts until one run is fast, then interpreting repeated elections under load as a safety requirement to weaken votes or quorums.
  • Calling catch-up complete merely when a leader is elected. A restarted node may still need snapshot installation, tail replication and application.
3

Try it yourself

Closed-book, before checking anything

Construct a synthetic five-voter timeline in logical ticks, not milliseconds. The leader receives one current-term command at tick 0, persists at tick 1, then sends one append to each follower. Successful durable-replication replies arrive at ticks 3, 5, 9 and 12; no other traffic or failures occur. It can commit at tick 5, applies at tick 6 and replies to the client at tick 7. Count eight protocol messages once all four request/reply pairs finish, excluding the client pair and later commit notification. Compare these distinct intervals, then use the same event boundaries in your local measurement campaign.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Why does the synthetic command commit at tick 5 rather than tick 12?Answer

    The leader is already durable and the second follower acknowledgement arrives at tick 5, giving three of five durable copies of a current-term entry. The other two followers are not required for that commitment.

  2. 2.A majority is unreachable and no new commands commit. Is that a safety failure?Answer

    Not by itself. It is expected unavailability under the majority contract. A conflicting application or lost committed entry would be a safety failure.

  3. 3.Does adding a voter necessarily increase measured latency?Answer

    No. It changes quorum size, order statistics and traffic, but the observed effect depends on topology, batching, scheduling and storage. Measure matched configurations rather than assert a universal direction.

  4. 4.What should a recovery-stall report include beyond a graph?Answer

    A replayable history, the bounded non-progress predicate, quorum and timing assumptions, invariant results and the event where progress resumes or its missing prerequisite.

You're done when

Your dossier reproduces the synthetic counts, labels local timing distributions with their setup and spread, and explains one bounded stall without weakening the safety contract or hiding unsuccessful requests.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 14 more in the section
  • MIT 6.5840 - Lab 3 RaftMIT PDOS · primary

    Complete Spring 2026 Lab 3A to 3D in order with the extended Raft paper, keeping the official tests (make RUN="-run 3A" raft1 and so on). The labs leave out membership change (Section 6) and lease reads, so those units use the paper. Then add deterministic message schedules, durable crash injection, state-machine invariants and minimized traces in your own harness.

  • In Search of an Understandable Consensus AlgorithmDiego Ongaro and John Ousterhout · required

    Read the extended Raft paper alongside each lab part. Maintain a one-page invariant ledger for election safety, log matching, leader completeness, state-machine safety and membership change.

  • Replicated Log and Stream Processor - Consensus SliceRoadmap-Final · support

    Add the reduced replicated log, persistence, snapshots and fenced ownership. Preserve a seeded campaign for partition, restart, stale leader, conflicting log and snapshot mismatch.

Also in this section

  • Consensus: Bridging Theory and Practice (Ongaro, 2014)Stanford University · required

    Use the thesis where the paper and the labs stop: Section 3.10 (leadership transfer), Chapter 4 (single-server membership changes, catching up new servers, removing the leader, disruptive servers, joint consensus), Section 6.4 (ReadIndex and lease-based read-only queries) and Section 9.6 (pre-vote).

  • Paxos Made Simple (Lamport, 2001)Leslie Lamport · support

    Read single-decree Paxos (prepare and accept phases, the safety argument) and the closing sketch of a replicated state machine, then map ballots to Raft terms. It is single-decree; a log needs the Multi-Paxos ordering layer.

  • Impossibility of Distributed Consensus with One Faulty Process (Fischer, Lynch and Paterson, 1985)MIT Theory of Distributed Systems group · support

    Read the model and the main theorem. It covers deterministic asynchronous consensus with one crash and says nothing against randomized or timeout-based protocols, which is why Raft needs timeouts only for liveness.

  • ZooKeeper: Wait-free Coordination for Internet-scale Systems (Hunt et al., 2010)USENIX ATC (MIT 6.5840 copy) · support

    Read the ordering guarantees, sessions and the Zab-based implementation, as MIT Lecture 9 does. Writes are linearizable; reads are served locally and may be stale unless preceded by sync.

  • The Chubby Lock Service for Loosely-Coupled Distributed Systems (Burrows, 2006)Google (author copy) · support

    Read the design sections on locks, sequencers and lock-delay and the Paxos-backed cell. Its locks are advisory; sequencers are how a resource rejects a stale holder.

  • etcd v3.7 API Guarantees and the etcd-io/raft Libraryetcd Authors · support

    Read the API guarantees page (strict serializability and revisions, linearizable versus serializable reads, leases, watch guarantees, uncertain outcomes after a timeout) and the raft library README (https://github.com/etcd-io/raft) for how a production library splits the protocol from storage and network.

  • Cambridge Concurrent and Distributed Systems Notes (Kleppmann) - Consensus and RaftUniversity of Cambridge (Martin Kleppmann) · support

    Use Chapter 6 (consensus, FLP and Raft election, replication and commitment) as a second explanation of the protocol, and work Exercise 18 (three Raft logs) before Lab 3B.

  • DDIA 2e - Chapter 10 Consistency and ConsensusMartin Kleppmann and Chris Riccomini · required

    Read consensus, total-order broadcast, linearizable storage and coordination sections after the first Raft implementation. Compare abstraction boundaries rather than memorizing protocol names.

  • Building Distributed Systems - The Elector and The ConsensusBuild Distributed Systems · optional

    Only the first three tasks of each track are free: in The Elector, node states, heartbeats and randomized timeouts; in The Consensus, log replication, log matching and commitment. Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.

  • How to Do Distributed Locking (Kleppmann, 2016) - Fencing TokensMartin Kleppmann · support

    Reread the fencing-token section when you add a lock or lease on top of your log: the term or log index becomes the token, and the resource must reject an older one.

  • HLD Handbook - Consensus ProtocolsHLD Handbook · support

    Use Part 3 consensus for visual review of Raft and Multi-Paxos after the invariant ledger is complete. Check any simplified production claim against primary papers or official system documentation.

  • MIT 6.5840 - Lab 4 KV RaftMIT PDOS · support

    Implement the key-value layer only after Raft invariants pass. Focus on client identity, duplicate suppression, snapshot state and request completion across leadership change.

  • DSLabs - Lab 3 PaxosUniversity of Washington (Ellis Michael) · support

    Labs are Java 21 message-passing state machines tested on an emulated network and by model-checking search tests that print a minimal violating trace; run them with the run-tests.py script and its --lab and --part options. Lab 3 is a Paxos-replicated service: compare its ballots, quorums and log slots with your Raft terms and indexes, and study how its search tests find and minimize violating schedules.

  • TLA+ Video Course - Transaction Commit and Paxos CommitLeslie Lamport · depth

    Watch lectures 5 to 7 (Transaction Commit, Two-Phase Commit, Paxos Commit) only after implementing Raft, check the course corrections page and run TLC on the matching specifications in the TLA+ Examples repository (https://github.com/tlaplus/Examples/tree/6a7b26a31c1a6aeec789b455e9bbfa3b3ad2728f/specifications/transaction_commit). Save the full TLA+ route for DS-9.