System Design
5. Advanced Database ArchitectureAnimated
Primary-Replica Architecture
A primary handles writes while replicas copy it and serve reads.
The idea
The modern name for master-slave. Replicas can be promoted if the primary fails.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
Normally all writes go to the primary.
- step:
- 1/6
- from:
- App
- to:
- Primary
1/6
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Clients write to the primary
- 2It replicates to replicas
- 3Reads go to replicas
- 4Failover promotes one replica
Where it is used
Most production databases.
Watch out for
Reading your own write from a lagging replica.