الانتقال إلى المحتوى
Software ArchitectureMicroservices· 7 دقائق للقراءة

Eventual Consistency Is a Product Decision, Not a Bug You Tolerate

The lag between copies is visible, so what users see during it, and what the system does with old data, are product decisions, not database settings.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

A shop moves its "My orders" page to a read model that the Orders service updates through events, and the page gets fast. Then support sees a pattern: customers cancel an order, the page reloads showing "Processing", and they press Cancel again. In the retro, one engineer proposes updating the read model inside the cancel request; another proposes a two-second wait before the redirect. Both treat the lag as a defect to hide. Nobody asks the product question: what should a customer see right after cancelling, and what should the warehouse do with an order that's cancelled but not yet known to be?

The common misconception

The belief: means the data is temporarily wrong. It's a compromise you accept for speed on things that don't matter, like a like counter, and never for orders, stock or money.

It's a fair reading of what people experience. Martin Fowler describes it from the user's side: "You make an update to something, it refreshes your screen and the update is missing." He calls it "a very irritating usability problem". And Azure Cosmos DB's docs give "count of Retweets, Likes, or nonthreaded comments" as examples of where eventual consistency fits.

The half-truth: the lag is real and can hurt. But in a microservices system, eventual consistency is the normal way data moves between services. Microsoft's guide says that when Catalog changes a price that Basket also stores, "the Catalog microservice should use eventual consistency probably based on asynchronous communication such as integration events". So the real question is how each feature behaves during the lag.

What actually happens

"Eventually" means old, not wrong

Werner Vogels defines it precisely: "the storage system guarantees that if no new updates are made to the object, eventually all accesses will return the last updated value." The gap has a name: "The period between the update and the moment when it is guaranteed that any observer will always see the updated value is dubbed the inconsistency window."

So a read during the returns a value that was true a moment ago. That's different from a wrong value. The harm comes from two things the storage won't do for you: showing an old value as if it were current, and making a decision on it as if it were final.

Every window has an audience

Who's looking changes everything. Other customers can't tell that an order list is two seconds old; the customer who just pressed Cancel notices at once. Vogels lists the guarantees for exactly that gap. : a process, "after it has updated a data item, always accesses the updated value and will never see an older value." Monotonic reads: once a process has seen a value, "any subsequent accesses will never return any previous values." Cosmos DB's session level gives you the first, and its docs say it suits "applications written to operate in the context of a user."

How long is acceptable is a product number, too. For a web site, Vogels' rule of thumb is that "the inconsistency window needs to be smaller than the time expected for the customer to return for the next page load." His summary puts the decision where it belongs: "Whether or not inconsistencies are acceptable depends on the client application."

Decisions made on old data need a business rule

Showing old data is the mild case. Fowler warns about the serious one: "Business logic can end up making decisions on inconsistent information, when this happens it can be extremely hard to diagnose what went wrong because any investigation will occur long after the inconsistency window has closed."

The warehouse that picks a just-cancelled order is that case, and no amount of speed removes it. Someone has to decide: does Shipping check with Orders before handing the parcel to the courier, or does a late cancellation become a return? Microsoft's basket example makes the same move: when a price changes, "the system should probably warn the user saying that a particular item's price has changed since they added it to their basket." That warning is a feature designed around the window, and the rule behind it is a business rule.

The business has done this for a long time

Fowler again: "Business processes are often more tolerant of inconsistencies than you think, because businesses often prize availability more". In our view, the best first question goes to the domain expert: what happened before software, when an order was cancelled after picking? There's usually a process already.

The fix: put the window into the API

The cancel endpoint below returns what the customer just did, and the order page refuses to show a state older than the customer's own change, a technique Vogels describes: "By adding versions on writes, the client discards reads of values with versions that precede the last-seen version."

C# Program.cs
var app = WebApplication.Create(args);app.MapPost("/orders/{id:guid}/cancel", async (Guid id, Orders orders) =>{    await orders.CancelAsync(id); // commits on the write side    // The order page reads a view that an event updates a moment later    return Results.Redirect($"/orders/{id}");});app.MapGet("/orders/{id:guid}", async (Guid id, OrderViews views) =>    await views.FindAsync(id) is { } v ? Results.Ok(v) : Results.NotFound());// The page can still say "Processing", so the customer cancels againapp.Run();

Nothing here makes the read model faster. The customer sees the cancellation at once because the write's own response says so, and a reload can't go backwards because the page knows which version the customer caused. "Within 5 days" is the product team's promise, since the refund runs later in another service. The warehouse dashboard still sees the window, by design. Keeping the events behind it from getting lost is a separate problem, solved by the outbox later in this path.

MythReality
Eventual consistency means wrong dataIt means possibly old data, and copies converge
It's only fine for likes and countersMost data between services is eventually consistent; each feature decides how to behave
Make it synchronous and it goes awayYou trade lag for coupling and lower availability, as the CAP article explains
Users can't cope with lagThey cope with an honest pending state, not with their own change vanishing
It's a technical detailWho sees what, how soon, and what wins a conflict are business rules

How to apply it in your project

  1. Find every copyList read models, caches, replicas and the data other services keep from your events. Each one has an inconsistency window, whether anyone chose it or not; the earlier caching article shows how a cache's window behaves.
  2. Ask product three questions per copyWho looks at it, how old may it be, and what does the screen say while it catches up? Write the answers next to the feature.
  3. Give the actor read-your-writesReturn the result and version of a write to the client that made it, or use your database's session guarantees, so nobody sees their own change vanish.
  4. Name the rule for stale decisionsFor every action taken on a copy, decide whether it checks the source first or gets compensated afterwards, and who owns that process.

Key takeaways

  • Eventual consistency means data can be old for a while, then converges; it doesn't mean the data is wrong.
  • The inconsistency window is visible, so who sees what during it is a product decision.
  • Give the person who made a change read-your-writes; other readers can usually live with the window.
  • Decisions made on old data need an explicit rule: check the source, or compensate later.
  • Ask how the business handled this lag before software; it often has a process already.

📚 المصادر

  1. Eventually Consistent - Revisited — Werner Vogels, All Things Distributed (2008)
  2. Microservice Trade-Offs — Martin Fowler (2015)
  3. Challenges and solutions for distributed data management — .NET Microservices e-book, Microsoft Learn
  4. Consistency level choices — Azure Cosmos DB, Microsoft Learn

التعليقات (0)