Skip to content
ADevGuide Logo ADevGuide
Go back

Consistency Models: Strong, Eventual and Read-Your-Writes

By Pratik Bhuite | 9 min read

Hub: Java / Interview Fundamentals

Series: Backend Interview Mastery

Last verified: Sep 19, 2026

Part 50 of 88 in the Backend Interview Mastery

Key Takeaways

On this page
Reading Comfort:

Consistency models compare strong, eventual, causal, and read-your-writes guarantees

After a profile update, the user refreshes and sees the old name. The write succeeded, but the read reached a lagging replica. “The database is consistent” is not specific enough: consistency is a contract about which order and visibility of operations readers are guaranteed to observe.

This consistency models guide compares strong, eventual, causal, read-your-writes, and monotonic-read behavior and shows how to choose a model per endpoint. Continue from CAP theorem, database replication, and isolation levels.

Table of Contents

Open Table of Contents

What Consistency Specifies

Consistency describes what values a read may observe relative to completed writes and other reads. It is different from database isolation, which describes what concurrent transactions can see while they execute. A system can use serializable transactions on one primary and still expose stale reads from a replica.

flowchart TD
    A[Client writes version 8] --> B[Primary commits]
    B --> C[Replica propagation]
    C --> D[Replica version 8]
    E[Client reads] --> F{Read target}
    F -->|Primary or synchronized replica| G[Strong result]
    F -->|Lagging replica| H[Stale result]
    E --> I[Session token: version 8]
    I --> J[Read-after-write routing]

Common Models

ModelGuaranteeTypical use
Strong/linearizableReads reflect the latest completed write in a real-time orderBalances, ownership, uniqueness
EventualReplicas converge if writes stop; reads may be staleFeeds, analytics, caches
CausalCause-and-effect operations are observed in orderConversations, collaboration
Read-your-writesA session sees its own successful writesProfile and settings pages
Monotonic readsA session never goes backward to an older valueProgress and status views

These models form a spectrum, not mutually exclusive database products. A system can provide eventual global convergence with read-your-writes sessions by routing a user to a replica at least as fresh as the write token.

Session Guarantees

Read-your-writes can use a primary route, a session cookie containing a commit version, or a replica wait condition. Monotonic reads can use a minimum observed version in the session context. Causal consistency can propagate a vector, logical timestamp, or dependency token with the request.

The token must be bounded and trustworthy. Do not let clients forge a version that grants access to future data, and do not store sensitive business state in a browser token. If the required replica cannot satisfy the token before the deadline, return a clear stale or retryable response instead of silently violating the contract.

Choosing Per Operation

An inventory reservation needs strong reads and conditional writes; a recommendation list can be eventual; an order status page benefits from read-your-writes; and a chat timeline often needs causal ordering. Ask what a stale read causes, what latency is acceptable, and whether a user can repair an incorrect answer.

Document the model in the API contract. “Eventually consistent” should include a freshness target such as “95% of reads converge within two seconds” and a fallback. Without an age or session guarantee, clients cannot decide whether to show, refresh, or reconcile a result.

Implementation Techniques

Use primary reads, quorum reads, synchronous replication, version checks, sticky sessions, cache invalidation, or change streams depending on the model. Stronger guarantees often increase latency, reduce availability during partitions, or consume more coordination resources. Measure replica lag and stale-read rate, not only database CPU.

Interview Questions

1. Is eventual consistency the same as no consistency?

No. Eventual consistency promises convergence when updates stop, while weaker designs may provide no ordering or convergence guarantee. Define the convergence window, conflict policy, and session behavior explicitly.

2. How do you implement read-your-writes?

Route the session to the primary, wait for a replica to reach the write’s version, or carry a commit token that the read path honors. Each option trades latency, load, and availability. The guarantee must survive retries and failover.

3. What is causal consistency?

Causal consistency preserves the order of operations that could have influenced one another while allowing unrelated operations to be observed in different orders. It is useful for conversations and workflows where a reply must not appear before the message it replies to. It is weaker and often more available than global linearizability.

4. How is consistency different from isolation?

Consistency is the distributed visibility contract across reads and replicas. Isolation is the database transaction contract for concurrent operations. Serializable isolation on one node does not prevent a remote replica from serving a stale committed value.

5. How would you choose a model for checkout?

Use strong consistency for inventory ownership, payment state, and uniqueness decisions. Use eventual projections for analytics, recommendations, and notifications. Keep the user-visible order status read-your-writes so a successful submission does not immediately appear missing.

Conclusion

Consistency models let a system make freshness and ordering explicit instead of hiding replica lag behind a vague guarantee. Use strong guarantees where stale data can cause a business error, session guarantees where user experience needs continuity, and eventual or causal models where latency and availability matter more than immediate global agreement.

References

  1. Jepsen: Consistency Models
  2. Apache Cassandra: Guarantees
  3. Google Cloud Spanner: External consistency

YouTube Videos

  1. “Consistency Models in Distributed Systems” - Distributed Systems Concepts [https://www.youtube.com/watch?v=DOFflggE_0Q]

Share this post on:

Next in Series

Continue through the [object Object] with the next recommended article.

Related Posts

Keep Learning with New Posts

Subscribe through RSS and follow the project to get new series updates.

Was this guide helpful?

Share detailed feedback

Previous Post
System Design Interview: Design an E-Commerce Platform
Next Post
Backend Interview Scenario: API Abuse and Quotas