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

App serversPrimary (writes)Replica 1 (read…Replica 2 (read…
  • 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

  1. 1Writes go to the master
  2. 2Changes stream to slaves
  3. 3Reads are spread over slaves
  4. 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.

Related