Database Replication
System Design: lesson 7 of 15
One writer, many readers, a small delay.
Lesson 7 of 15 · 6 min
Database Replication
Step 1 of 12
Replication keeps extra copies in step. One writer, many readers, and a small delay.
The Idea
Replication keeps extra copies of a database in step. Writes land on the primary, which streams its changes to replicas, and reads can be served from any copy. That multiplies read capacity and gives you a standby to promote when the primary dies. It does not multiply write capacity.
Real-World Example
A land registry keeps the authoritative ledger in the capital and read-only copies in county offices. Checking a title locally takes minutes. A deed registered this morning may not appear in your county until the day's changes have travelled up the road.
The Tradeoff
Asynchronous replication is fast but lets a user read their own write and see the old value. Synchronous replication removes that and makes every write wait for an acknowledgement. Failover while a replica is behind can lose committed transactions, so decide up front which reads are allowed to be stale.
Your turn
Put the steps in the right order.
- The replica applies the change to its own copy
- A write is committed on the primary
- Read queries are routed to whichever replica is free
- The change is streamed out to each replica
Mini quiz
1 / 3