# Cheat Sheet: Everything on One Page — Distributed Systems & Consensus (Raft / Paxos)

Source: https://www.skillbyai.com/en/distributed-consensus/dc-cheat-sheet

> Recall the key definitions, numbers and rules of consensus in one pass before an exam or interview.

## The one-page summary

**Models**: crash-recovery nodes, unreliable network, partial synchrony; Byzantine needs 3f + 1, crash needs 2f + 1. **Time**: never order events by wall clocks across nodes; Lamport clocks give a causal total order, vector clocks detect concurrency. **Quorums**: W + R > N for overlap; consensus uses majorities, and any two majorities intersect. **Consensus**: agreement, validity, termination; FLP forbids guaranteed termination in a fully asynchronous system with one crash. **Paxos**: Prepare(n) -> Promise (report accepted values) -> Accept(n, v) with the highest-ballot reported value -> chosen on a majority. Multi-Paxos skips phase 1 with a stable leader. **Raft**: follower, candidate, leader; terms as a logical clock; RequestVote with the up-to-date check; AppendEntries with prevLogIndex/prevLogTerm; commit only current-term entries by counting; single-server membership changes; snapshots with InstallSnapshot; ReadIndex for linearizable reads; Pre-Vote and CheckQuorum for stability. **Practice**: odd cluster sizes, fsync before replying, fencing tokens at the resource.

## How to revise this course

Re-read the cheat sheet, rehearse the common interview questions aloud, then test yourself with the mixed self-check.

![Three stages: cheat sheet, interview questions, and self-check quiz.](assets/figures/distributed-consensus/section-11-map.svg) — Figure 11.1: cheat sheet -> interview questions -> self-check

## Numbers worth memorising

3 nodes tolerate 1 crash, 5 tolerate 2, 7 tolerate 3. BFT: 4 tolerate 1, 7 tolerate 2. 2PC needs every participant; consensus needs a majority. Raft paper example election timeout: 150-300 ms, randomised.

**Quiz:** Which pairing is correct?

- [x] Vector clocks: detect concurrent events; Lamport clocks: total order consistent with causality
- [ ] Lamport clocks: detect concurrent events; vector clocks: wall-clock order
- [ ] Both give the real-time order of events
- [ ] Neither respects happens-before

*Answer:* Vector clocks: detect concurrent events; Lamport clocks: total order consistent with causality. Lamport clocks respect causality and can be made a total order with tie-breaking, but cannot prove concurrency; vector clocks can.
