Lesson 12 of 17
14. Replication

Memory card and where the analogy breaks

3 min read+10 XP

The memory card (tear this page out)

#QuestionMemory code
14.1Why replicate?Copies for safety, for crowds and for distance, but never instead of a backup
14.2Leader-follower?One office writes, every branch files the copies in order
14.3Sync vs async?Wait for a copy and be safe, or don't wait and be fast
14.4Replication lag?The courier can fall behind; always know by how much
14.5Fixes for lag?Show people their own changes, and never let time run backwards
14.6Read replicas?Reads to the branches, changes to head office
14.7Failover?Notice, choose the freshest, promote, redirect, and silence the old boss
14.8Split brain?Only a majority can crown a leader, and the old crown must stop working
14.9Multi-leader?Many offices, many pens, and someone must settle the arguments
14.10Leaderless quorums?Write to most, read from most, and the newest version wins

The whole chapter in one line: One office writes, branches copy in order, know how far behind they are, and only a majority may crown a new head office.

Where the analogy breaks

  • A courier takes hours. Replication usually takes milliseconds, which is why lag problems show up as rare, confusing bugs rather than obvious delays.
  • A burnt office is obviously gone. A failed server often isn't: it may be slow, half-working or cut off, which is exactly what makes failover and split brain hard.
  • Branches can phone each other to compare notes. Replicas can't trust each other's clocks, so "which write was last?" is much harder than it sounds.

Quick check

Five questions on this chapter. Pick an answer, then check it.

quiz