Monotonic Reads
What You'll Learn
You'll learn how monotonic reads guarantee that once you see a certain version of data, you'll never accidentally travel backward in time on future reads.
The Core Idea
In distributed systems with eventual consistency, different replicas may have slightly different versions of the same data. Monotonic reads is a consistency guarantee that ensures: once you've read a particular value (or version) for a key, all subsequent reads will return that value or a newer one—never an older version.
Without this guarantee, you might read version 5 of a document on one request, then accidentally read version 3 on the next request if your queries hit different replicas that are catching up at different speeds.
Why It Matters
Imagine checking your bank account balance:
- First check: You see $500 (replica A, up-to-date)
- Second check: You see $300 (replica B, lagging behind, showing old state)
This backward time-travel violates user expectations. Monotonic reads prevent this by ensuring you either read from the same replica (session stickiness) or only from replicas that are at least as up-to-date as what you've already seen.
How Systems Achieve It
Common techniques include:
- Sticky sessions: Route all reads from one user to the same replica
- Version vectors: Track what version the client has seen; reject reads from lagging replicas
- Read-your-writes + monotonic reads together: Common pairing for user-facing systems
Key Takeaway:
Monotonic reads guarantee forward progress—once you've seen version N, you'll never see anything older than N, preventing confusing time-travel experiences for users.