Skip to the guide

Replication lag and read-your-writes

IntermediateConcept3 pages

Followers apply the leader's changes a moment later. Most of the time nobody notices; then a user saves her new profile photo, refreshes, and the old one is back. Interviewers bring this up as soon as you add read replicas: what can a user see, and how do they always see their own changes?

The town hall counters

You change your address at counter 1 of the town hall, where the clerk updates the register. Counter 2 works from a copy that's brought up to date every few minutes. Walk straight over to counter 2 for a parking permit, and she says you still live at the old address. Three ways to avoid that: go back to counter 1 for anything about yourself; show counter 2 your receipt number and ask her to wait until her copy includes it; or always use the same counter, so the answers never go back in time.

  • counter 1 → the leader; counter 2 → a follower
  • the copy updated every few minutes → replication lag
  • seeing your own change → read-your-writes
  • the receipt number → the log position of your write
  • always the same counter → monotonic reads