Users see stale data right after saving because reads go to a replica with lag. How do you handle it?

IntermediateScenarioData and databases
Answer

Situation read → Asynchronous replicas are always slightly behind. The fix is choosing which reads need to be fresh, and making sure lag stays low.

What I'd do →

  1. Measure lag: ReplicaLag in CloudWatch (RDS) or AuroraReplicaLag, and alert on it.
  2. Find why it's high: big batch writes, long queries on the replica blocking replay, or an undersized replica.
  3. Route "read-your-own-writes" reads to the primary: for example, for a few seconds after a user writes, or for the specific pages that show what was just saved.
  4. Keep the replica for reporting, search and lists where a few seconds of staleness is fine.
  5. On Aurora, replicas share storage, so lag is usually milliseconds, which may remove the problem.

Why → Not every read needs to be consistent; send only the ones that do to the primary.

Interview tip → Use the phrase "read-your-own-writes"; it names the exact consistency issue.

All Real-World Interview questions Roadmap: Interview readiness

More on Data and databases