Lesson 2 of 17
14. Replication

14.1 Why keep copies of the same data?

3 min read+10 XP

The basics

At the bank: Copies at every branch mean customers don't all travel to head office (less crowding), customers in far cities read notices nearby (faster), and if head office is lost, the notices still exist (safety).

In the system: Replication keeps the same data on several machines, called replicas. Three reasons:

  1. Survive failures (availability and durability): if the machine holding the data dies, another copy takes over. Without replicas, one disk failure can mean lost orders.
  2. Scale reads: spread read traffic across copies. The bookstore's browsing (book pages, search results) is mostly reads (Chapter 2's read/write ratio).
  3. Be closer to users: a copy in another region serves nearby users faster (Chapter 7, section 7.10).

What replication doesn't do:

  • It doesn't help write throughput in the common setup: every copy must apply every write. Splitting writes is sharding (Chapter 15).
  • It isn't a backup. Delete a table by mistake, and the delete is faithfully copied everywhere within seconds. Keep separate backups.

Memory code: "Copies for safety, for crowds and for distance, but never instead of a backup."