System Design Playbook
09 · Data & databases7 min read

Read replicas: what they are and when to use them

Copies of your database that stay in sync with the primary and serve read queries. How replication works, what replication lag means for your users, and when replicas are (and aren't) the right tool.

In one sentence

A read replica is a copy of the database that receives every change from the primary and answers read queries, so you can add read capacity without touching writes.

How it works

All writes go to one primary. The primary records each change in a log and streams it to one or more replicas, which apply the same changes. Your app sends writes to the primary and spreads reads across the replicas.

Primary + read replicas
App serverswrites + readsPrimaryv1Replica 1v1Replica 2v1Replica 3v1Ana updates her name, then reloads her profilewritesreads
Lag
1200 ms
Stale reads
0
Fresh reads
0
Reads on primary
0%
Writes always go to the primary, which streams changes to the replicas. Reads are spread across replicas, so read capacity grows with each replica. The catch: a replica can be a little behind (replication lag).
Increase the lag and watch Ana read an old version of her own profile; then turn on read-your-writes.

Replication lag

Most replication is asynchronous: the primary confirms the write before replicas have it. Usually the gap is milliseconds, but under heavy load, long transactions or network trouble it can grow to seconds or more.

The visible symptom: a user saves something, the page reloads from a replica, and their change isn't there yet.

  • Read-your-writes: after a user writes, send that user's reads to the primary for a few seconds (or until the replica catches up).
  • Sticky by version: remember the write's position in the log and only read from replicas that have reached it.
  • Critical reads on the primary: "show my balance before paying" always reads the primary.
  • Synchronous replicas for zero lag, paying with slower writes.

When to use read replicas

Good fit

  • The database CPU is mostly spent on reads
  • Reporting or analytics queries that shouldn't slow down the app
  • Serving users in another region with a nearby copy
  • A ready standby: a replica can be promoted if the primary dies

Not the fix

  • Writes are the bottleneck: every replica must apply every write too (look at sharding, queues, batching)
  • Reads that must always be perfectly fresh
  • A missing index: fix the query before adding machines

Key takeaways

  • 01Writes go to the primary; replicas copy every change and serve reads.
  • 02Replicas scale reads, not writes.
  • 03Asynchronous replication means lag: design read-your-writes for flows where users expect to see their change.
  • 04Replicas also provide failover and keep heavy reports away from production traffic.

Check your understanding

1 of 3

Where do writes go in a primary-replica setup?

Related concepts