A read replica is a copy of your database that answers reads. The primary still takes every write, and the replicas follow along. That makes replicas a very good fix for one problem, too many reads, and no fix at all for the other one, too many writes. The trouble is that from the outside both look the same: the database is pinned.
The experiment
A gift shop takes 1,700 requests a second: 65% reads, 20% saves (writes), 15% static files. Five medium app servers talk to one small SQL database. Last week someone added two read replicas, to be safe.
Thirty seconds in, the shop asks everyone to build a wishlist. Saves jump to 60% of traffic and reads fall to 25%. Same number of requests, different mix. We ran it with five database setups, with the same seed each time.
| Database | Mostly reads | Mostly writes | Simulated cost / month |
|---|---|---|---|
| Small, no replicas | 43.7% | 35.5% | $1,023 |
| Small, 2 replicas | 99.99% | 45.7% | $1,313 |
| Small, 4 replicas | 100% | 59.4% | $1,603 |
| Medium, no replicas | 100% | 99.93% | $1,241 |
| Medium, 2 replicas | 100% | 100% | $1,966 |
The middle columns are availability before and after the switch. Costs are for the whole system during the write-heavy part. InfraSim, Advent of Outages door 3, seed 261203.
What the replicas did
While people were browsing, the replicas were doing real work. Without them the small database failed more than half of all requests. With two, it held 99.99%. If your database is pinned and most of its work is reads, a replica is often the cheapest fix there is.
Then the saves arrived, and the same setup fell to 45.7%. Nothing broke. The replicas were still there, still healthy, and suddenly had little to do, because the work moved to the one place they cannot help: the primary.
Why more replicas barely helped
Doubling to four replicas lifted the write-heavy phase from 45.7% to 59.4% and added $290 a month. The extra replicas pulled the last of the reads off the primary, which freed a little room, but the saves on their own were more than a small primary could take.
In InfraSim's model a replica adds capacity in proportion to the share of the database's work that is reads. When reads are 65% of requests, two replicas are a big deal. When reads drop to 25%, the same two replicas are worth much less, and no number of them touches the writes.
The fix that worked
A medium primary with no replicas at all held 99.93% through the rush of saves, and cost $1,241 a month: less than the small primary with two replicas that failed. Writes need a bigger primary, or fewer writes (batching them, or moving work like counters and logs somewhere else), or splitting the data so different primaries take different writes.
The lesson is not "replicas are bad". It is "check which kind of request is filling the primary before you pick the fix".
One more thing replicas change
A replica applies the primary's writes a moment later, so it can answer with slightly old data. That is fine for a product page and surprising for a user who just saved something and reloads their wishlist. Systems that read from replicas usually send a user's own reads to the primary for a short time after they write.
About these numbers
They describe InfraSim's simulation, which models flows of requests per tick, not individual queries, with a fixed seed so each run repeats exactly. Costs are the game's simulated monthly figures, not any provider's prices.
Break it yourself
This is Advent of Outages door 3, "Saved for Later": the same shop, the same two replicas, the same rush of saves. Free in your browser with no account; the door opens on 3 December and stays open after.
In the InfraSim app, Replica Relief (chapter 3, Data Bottlenecks, free) is the opposite case: a feed of personalized reads that a cache cannot help with, where replicas are the right answer.
New to InfraSim? The first five campaign levels play in your browser right now. No install, no account.