What are Monotonic Reads?

First of all the problem case…

The problem: anomalies can occur when reading asynchronous followers!

  • It possible for a user seeing things move backwards in time
    • This can happen if a user makes several reads from different replicas 😵
  • Example of this:
    • User 1 2 3 makes some query twice from a follower with a little lag and another follower with greater lag
      • This scenario can occur when a user refreshes a webpage and each request is routed to a random server
        • The first query returns a comment from user 4 5 6 and the second query does not return anything as the lagging follower has not picked up that write…
          • In effect the second query is observing an earlier point in time
    • This may not be too much of a stress as user 1 2 3 does not know whether user 4 5 6 has added a comment…🤷‍♂️
      • ❌ Although this is very confusing for user 1 2 3 if they first see user 4 5 6 comment appear and then disappear again

Monatonic Reads to the rescue?

Well this method is a weaker guarantee than strong consistency, but a stronger guarantee than eventual consistency. For more readings on strong consistency vs eventual consistency please read my previous blog post.

When you read data you may want to see an old value…

  • Monotonic reads makes sure that when a user makes several reads in sequence, it won’t go backwards ✅
  • Will not read older data after previously reading newer data ✅

How do we achieve Monatonic Reads?

One way to achieve monotonic reads is to make sure each user always makes there reads from the same replica.

  • Meaning, different users can read from different replicas
  • ⚙️ The replica can be chosen based on the hash of the user ID rather than randomly
  • ⚠️ However… if that replica fails the user queries will need to be re-routed to another replica…
    • Which in a way, reverts back to pure eventual consistency method, where you may have varying results on different replicas.

📚 Further Reading & Related Topics

If you’re exploring monotonic reads and consistency models in distributed systems, these related articles will provide deeper insights:

• Reading Your Own Writes in Distributed Data-Intensive Systems – Understand how ensuring users see their own updates is closely related to monotonic read consistency.

• Distributed Data-Intensive Systems: Logical Log Replication – Learn how replication mechanisms impact read consistency and data freshness across distributed nodes.

3 responses to “What are Monotonic Reads?”

  1. Part 1: Top 5 Considerations Designing Data-Intensive Applications – Scalable Human Blog Avatar

    […] • What Are Monotonic Reads? – Understand how consistency models impact the design of scalable, data-intensive systems. […]

    Like

Leave a comment

I’m Sean

Welcome to the Scalable Human blog. Just a software engineer writing about algo trading, AI, and books. I learn in public, use AI tools extensively, and share what works. Educational purposes only – not financial advice.

Let’s connect