CodePark/ questions / CAP, consistency & distributed data
START PRACTICINGPRACTICE
Backend question · System design & architecture › CAP, consistency & distributed data

A user edits their profile, the page reloads, and the old name appears. Writes go to the primary and reads go to asynchronous replicas. Which fix gives read-your-writes at the lowest cost?

Route that user's reads to the primary for a short window after they write

Read-your-writes only means a user must see their own writes. So the cheap fix is to "Route that user's reads to the primary for a short window after they write". You can also send them to a replica that is known to have caught up.

The other options are worse:

• "Make all replicas synchronous" also works, but it slows down every write in the whole system.

• "Add more read replicas" does not help, because the new replicas can also be behind.

• "Put a CDN in front of the profile API" makes the stale reads worse, because the CDN caches the old name.