Last Minute Notes
  • Github
  • Docs
  • Learn
    @sayanstwt
Lessons
0/37 done
  • CAP & PACELC
  • Consistency Models
  • Time & Ordering
  • Consensus with Raft
  • Locks, Leases & Fencing
  • Isolation Levels & Anomalies
  • 2PC & Sagas
  • Idempotency & Exactly-Once
Learn/System Design/Distributed Systems

Consensus with Raft

9 min Advanced 9 steps

Elect a leader, replicate a log, survive failures.

Nodes
5
Values of x
2
Agreement
none
Node 1x=5x is 5?Client 1Node 5x=5Node 2Client 2Node 4x=7Node 3x=7x is 7?x=5x=7without consensus, replicas diverge
request response data
In this lessonStep 1 of 9
  1. The problem
  2. Roles, terms
  3. Election
  4. Replicate
  5. Split vote
  6. Safety
  7. Cluster size
  8. Partitions
  9. Recap
Step 1 / 9problem

Replicas that do not agree

Two clients write different values of x to different nodes. Each side copies its value around, and the cluster now holds two answers.

Consensus lets a group agree on a value, or a log of values, even when nodes crash and messages are delayed.

Key idea

Consensus is the base of leader election, config stores like etcd, and strongly consistent databases.

←→ step·R replay·Space pause

You'll learn

  • What consensus is for and why a majority matters
  • How Raft elects a leader with terms and random timeouts
  • How an entry is replicated and committed
  • Why committed entries survive leader changes
  • Pick a cluster size and know the cost
Read the full notesDistributed Systems, 4