map / distributed-systems / consistency
Distributed Systems · principle 4 of 6
Consistency models
Consistency models are promises about which values a read may return; stronger promises cost coordination, and coordination costs latency.
01 · Why it’s true
Copying data between machines takes time. When a client writes to one replica and then reads from another that hasn’t received the update, it sees old data.
A system can hide this by making reads go to the leader or wait for replicas to catch up — at the cost of latency and availability — or accept it and give weaker guarantees, such as “eventually all replicas agree”. Many systems offer middle ground, such as read-your-writes: a client always sees its own updates.
02 · Picture it
03 · In the interview
- Explaining replication lag and the user-visible bugs it causes.
- Choosing which reads must be strongly consistent and which can be stale.
- Naming practical patterns: read from the leader after a write, sticky sessions, version tokens.
04 · Practice question
“Users update their profile, refresh the page, and sometimes see the old version. What’s happening and how do you fix it?”
A strong answer covers
- Writes go to the primary, but reads are served from replicas that lag behind.
- Confirm by checking replication lag when the reports occur.
- Fixes: read-your-writes — send a user’s reads to the primary for a short window after they write, or pass a version and wait for a replica that has it.
- Keep cheap replica reads for data where a little staleness is fine.