System Design Intermediate

03  Scaling Reads & Writes

One database eventually stops being one database. Replicas multiply your read capacity, shards split your write load -- and each introduces brand-new ways to be wrong that a single box never had.

Step 1 / 2

You add read replicas in front of a busy primary and route all reads to them. A user edits their display name, the page reloads, and shows the OLD name. Explain exactly why this happens, then give two fixes and the cost of each.

Hints
  • The write went to the primary. Where did the reload read from, and had the write arrived there yet?
  • Fix family one: route THIS user to data that already contains their write -- read-your-own-writes.
  • Fix family two: make replication itself wait. What does that cost every write?
Your design is reviewed against a hidden rubric.