Replication & Stale Reads
The trade you are making
A read replica is a copy of your database that receives a stream of changes from the primary and serves reads. Since most workloads are read-heavy, this is often the cheapest large capacity win available.
With asynchronous replication, the copy may lag the primary: sometimes caught up, sometimes milliseconds behind, and potentially much further behind under load or failure. Synchronous replication can tighten the guarantee by putting replica acknowledgement on the write path, trading write latency and availability for freshness.
So a read from a replica may return a value that was true a moment ago and is not true now. Usually harmless. Occasionally catastrophic: a user updates their profile, the next page load reads a replica, and their change has visibly vanished. They will try again, and now you have two problems.
WRITE primary balance = $900
↓ replication lag: 220 ms
READ replica balance = $1000 ← older snapshot
The write succeeded. The replica read reflects
an earlier point in the database history.3 components2 connections0:00
Recording…