SOFTWARE ENGINEERING · ~10 MIN READ

Consistency Patterns
in Distributed Systems

Two customers buy the last copy of the same book at the same time. Which service "wins"? The right answer depends on one thing: which consistency pattern the system chose — and that choice changes how the system behaves under pressure.

Consistency in distributed systems: order service, stock service, payment service and delayed replica showing when a write becomes truth. The image summarizes strong, weak and eventual consistency.

SECTION 01

What a distributed system is

Before talking about consistency, it helps to align on a simple idea: a distributed system is an application split into several parts, each running separately, that communicate over the network to deliver one result.

Take an online bookstore. Instead of one server doing everything, the application might be split like this:

Sketch diagram of a distributed online bookstore: client, orders, payment, stock, accounts, loyalty and a stock database connected by network messages.
DISTRIBUTED SYSTEM · ONE APPLICATION, MANY SERVICES

Each service has one responsibility and, often, its own database. The article on microservices in practice covers that split in more detail — here the question is narrower: what happens to the data once it is spread out like this.

GOING DEEPER

A common definition says a distributed system is a set of components located on different networked computers, communicating and coordinating their actions by passing messages in order to reach a common goal.

SECTION 02

Why consistency is a problem

When data lives in more than one place, something has to make sure those copies do not tell different stories. Back to the bookstore: the Stock Service needs to know exactly how many copies of a book exist when someone tries to buy it.

Now imagine two customers looking at the same book — only 1 copy left — at the same time:

Race condition: Client A and Client B both read stock equals 1 and confirm the purchase, producing an invalid stock of -1 and a duplicate sale.
RACE CONDITION · TWO ORDERS FOR ONE COPY

This is a classic race condition: between the moment Client B reads the stock and the moment the Stock Service finishes processing Client A's purchase, the information became stale — and nobody noticed in time.

That is exactly what consistency patterns define: when, precisely, a write made in one place becomes visible to a read made somewhere else.

SECTION 03

The three families of patterns

There is no universal answer to "when should data synchronize." There is a trade-off between three things: how fast the system responds, how available it remains when something fails, and how exact the information is. The most common consistency patterns make that trade-off in three ways:

Three consistency families: strong sees the latest write, weak may read old data, and eventual converges over time.
STRONG · WEAK · EVENTUAL

Eventual consistency is not an entirely separate category — it is a specific, well-behaved form of weak consistency. It does not promise when a read will reflect a write; it only promises that, if no new writes arrive, all replicas converge to the same value over time.

SECTION 04

Strong consistency

The rule is simple to state: after a write completes, every following read — no matter which replica it hits — sees that write immediately. For that to work, replication must be synchronous: every copy is updated before the system confirms that the operation finished.

Strong consistency: a client sends a critical bank transfer to a coordinator, which waits for replicas A, B and C to confirm before completing the write.
STRONG CONSISTENCY · SYNCHRONOUS REPLICATION

A financial system is the classic example: nobody should see an account balance "almost" updated. The cost is clear — because the system waits for all replicas to confirm before responding, latency rises and availability drops when a replica is down.

GOING DEEPER

This trade-off has a name: the CAP theorem says that, during a network partition between replicas, a distributed system can only preserve two of three guarantees — Consistency, Availability, and Partition tolerance. Since partitions are unavoidable in production, the practical choice is between consistency and availability when things go wrong.

SECTION 05

Weak consistency

Here the promise is looser: after a write, a later read may see the change — or may not. There is no deadline and no ordering guarantee. That sounds risky, but it is exactly what makes sense when speed matters more than absolute precision.

Weak consistency in an online game: Player A sees the movement now, Player B may see it later because of lag, and the game continues.
WEAK CONSISTENCY · LOW LATENCY

In a multiplayer game, actions appear immediately for players close to the same server. If someone has lag or an unstable connection, that player may not see an action in time — and the game does not freeze waiting for them. That creates real inconsistency between screens, but also preserves the low latency the match needs.

SECTION 06

Eventual consistency

Eventual consistency takes weak consistency and adds one promise: if no new writes arrive, all replicas eventually converge to the same value. Replication is asynchronous — the system responds before propagating the change everywhere.

Eventual consistency: a post appears in São Paulo first, Frankfurt and Singapore temporarily show the old state, and later all replicas converge.
EVENTUAL CONSISTENCY · ASYNCHRONOUS REPLICATION

A social network is the intuitive example: data lives in several datacenters around the world. When someone posts, the update appears immediately in the local datacenter, but takes a little time to propagate to others. During that window, different people literally see different versions of the same feed — by design, not by accident.

GOING DEEPER

In practice, "eventually" often comes with stronger tools: quorum reads, which require responses from N of M replicas before a read is accepted, and causal consistency, which preserves the order of related writes even without strong consistency everywhere.

SECTION 07

Comparing the three patterns

Side by side, the trade-off becomes easier to see:

Hand-drawn table comparing strong, weak and eventual consistency by latency, availability, integrity and replication.
TRADE-OFFS · LATENCY, AVAILABILITY AND INTEGRITY

No row in this table is "better" in absolute terms. Each pattern is right for a different kind of problem. That is why real large systems often mix all three, each applied to a different part of the architecture.

SECTION 08

How to choose in practice

Before choosing a pattern, three questions help diagnose what the data actually requires:

  • Would wrong data cause real damage? Account balances, final payment stock, access permissions — these usually need strong consistency.
  • Can the system afford to wait for synchronization? If not, some form of weak or eventual consistency is often necessary.
  • Is a small propagation delay acceptable? Likes, view counts, feeds, caches and DNS usually tolerate eventual consistency.
Decision guide: strong consistency for balances, payments and single stock; weak consistency for online games, telemetry and real time; eventual consistency for feed, likes, cache and DNS.
DIAGNOSIS · HOW TO CHOOSE THE PATTERN

This choice does not have to be global. In the bookstore from the beginning, payment may require strong consistency while the count of "how many people viewed this book today" can safely use eventual consistency.

SECTION 09

Conclusion

Consistency is not a yes-or-no box — it is a spectrum, and every point on it costs something different:

SUMMARYTEXT
Strong consistency:
trades speed and availability for guaranteed correctness.

Weak consistency:
trades exactness for speed and high availability.

Eventual consistency:
accepts temporary delay, but guarantees convergence.

The right question is never "which consistency pattern is best." It is: "what can this specific data not afford to get wrong, and what can it afford to wait for?" Answering that data by data is what separates a well-designed distributed architecture from one that only seems to work until two orders arrive at the same time.

THE END · THANKS FOR READING

Want to see these decisions applied to a whole system?

The System Design article shows how cache, databases and asynchronous communication fit into the same trade-offs between consistency, availability and latency.

READ SYSTEM DESIGN BACK TO CONTENTS