System Design
5. Advanced Database ArchitectureAnimated
Master-Slave Replication
One writer, many read-only copies.
The idea
The master takes writes and streams changes to slaves that serve reads. The newer term is primary-replica.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- client
- gateway / proxy
- service
- cache
- data store
- queue / stream
Step one: add indexes and cache.
- step:
- 1/4
- at:
- App servers
1/7
The green dot is a request moving through the system.
Step by step
- 1Writes go to the master
- 2Changes stream to slaves
- 3Reads are spread over slaves
- 4A slave can be promoted on failure
Where it is used
Read-heavy workloads.
Watch out for
Replica lag causes stale reads, and the master is a write bottleneck.