Notesreplication🌱 seedling
Monotonic Reads
Also: Monotonic Read Consistency
A session guarantee: once you've seen some state, you never later see an older one. Stale is allowed; going backwards isn't.
Why it exists
Two reads from one user can hit two followers with different lag. The first shows a new comment, the second (from a more lagged replica) doesn't, and time appears to run backwards.
How it works
- Pin each user's reads to one replica, e.g. by hashing the user ID to choose it.
- If that replica fails, rerouting may step back once, unless the client carries a log-position token and the new replica waits until it has caught up to it.
- It's weaker than strong consistency and stronger than plain Eventual Consistency.
Trade-offs
| Gains | Costs |
|---|---|
| cheap: just sticky routing | uneven load if some users are heavy |
| no leader involvement | failover of the pinned replica can break it without tokens |
In practice
- Load balancers with session affinity, or replica selection by user-ID hash, provide it for free in most web apps.
Pitfalls
- Round-robin across read replicas violates it by design.
Connections
- Part of
- Replication Lag
- Mentioned
- Eventual Consistency
Recall
These cards are also in your review deck, scheduled with spaced repetition.