Single database vs read replicas

One database serves every read and write. Read replicas copy the data and serve the reads, so the primary keeps its CPU for writes. At 10,000 reads/s and 1,000 writes/s, one database gives p99 4,160 ms. A replica set gives p99 24.8 ms for 16 USD/mo more.

Play the level

Copies and the write quorumDrag or use arrow keys to change the write quorum

Quorum 2 of 3 · commit 9.0 ms

One server boardDrag or use arrow keys to change the load

280 req/s · CPU 70% · mean 22 ms

Case 1

11,000 requests/s, of which 10,000 are reads. p99 must stay below 100 ms and replica lag below 1 s.

Case 1
Measure Goal One database Primary with read replicas
p99 latency under 100 ms 4.2 s Fail 25 ms Pass
Replica lag under 1 s 0 s Pass 0.1 s Pass
Monthly cost 8 USD/mo 24 USD/mo
Error rate 3.8% 0%
SQLUsersPostgres1 vCPU · 2 GB
SQLUsersPostgres1 vCPU · 2 GB
One database: misses a goal
SQLUsersPostgres1 vCPU · 2 GB × 3
SQLUsersPostgres1 vCPU · 2 GB × 3
Primary with read replicas: meets the goals

Case 2

The same database at 2,000 requests/s. Both layouts give p99 24.8 ms, and one database costs 16 USD/mo less.

Case 2
Measure Goal One database Primary with read replicas
p99 latency under 100 ms 25 ms Pass 25 ms Pass
Replica lag under 1 s 0 s Pass 0.1 s Pass
Monthly cost 8 USD/mo 24 USD/mo
Error rate 0% 0%
SQLUsersPostgres1 vCPU · 2 GB
SQLUsersPostgres1 vCPU · 2 GB
One database: meets the goals
SQLUsersPostgres1 vCPU · 2 GB × 3
SQLUsersPostgres1 vCPU · 2 GB × 3
Primary with read replicas: meets the goals