Skip to content
StackDecode
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.

AppPrimaryReplicaMonitorwrites
  • 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

  1. 1Clients write to the primary
  2. 2It replicates to replicas
  3. 3Reads go to replicas
  4. 4Failover promotes one replica

Where it is used

Most production databases.

Watch out for

Reading your own write from a lagging replica.

Related