Course contentsShow
← Software Engineering
Lesson 925 of 1,93328. Transactions and ConsistencyFree lesson

Read-Your-Writes and Monotonic Reads

Learn about session consistency guarantees that improve user experience in eventually consistent systems.

Read-Your-Writes and Monotonic Reads

You'll learn how two session consistency guarantees—read-your-writes and monotonic reads—make eventually consistent systems feel more predictable to individual users.

When working with eventually consistent systems (like replicated databases), users can experience confusing scenarios: they submit data but don't see it immediately, or they see their feed update and then it rolls back. Two session-level guarantees address these problems without requiring full strong consistency.

Read-Your-Writes Consistency

Read-your-writes guarantees that after a user writes data, any subsequent reads by that same user will reflect that write—even if other users might not see it yet.

Analogy: You post a comment on a social media site. Read-your-writes ensures you see your comment immediately when you refresh, even if it takes a few seconds to propagate to servers worldwide for everyone else.

Implementation pattern: Track which writes a user session has made (often via version numbers or timestamps), and route that user's reads to replicas that have caught up to at least those writes.

Monotonic Reads Consistency

Monotonic reads ensures that once a user reads a certain state of data, subsequent reads will never show an older state—time doesn't move backwards for that user.

Analogy: You check your bank balance and see 100.Fivesecondslateryoucheckagain.Monotonicreadsguaranteesyouwon′tsuddenlysee100. Five seconds later you check again. Monotonic reads guarantees you won't suddenly see 80 (an older value before a recent deposit arrived). The balance might stay $100 or increase, but never decrease due to stale data.

Implementation pattern: Bind a user's session to a specific replica, or track the "read timestamp" and ensure subsequent reads happen from replicas at least as up-to-date.

Key Takeaway: Read-your-writes and monotonic reads are session guarantees that make eventually consistent systems feel reliable to individual users without requiring expensive global consistency—improving user experience while maintaining availability.