liveBook · Manning

Eventual consistency

As explained in Grokking Software Architecture

Eventual consistency is a consistency model in which distributed state may temporarily differ but converges to a consistent state after updates propagate.

Where did my order go?

A customer places an order and immediately refreshes Recent Orders. The shipping status still says “Pending,” or the order is missing, because the shipping service has not processed the message yet. The order and shipping views temporarily tell different stories. section 7.3

Eventual consistency allows distributed state to differ temporarily as updates propagate. If no new updates are made to a data item, accesses to it will eventually return the last updated value. The promise is convergence, not an instant update or a specified waiting time. section 7.3.1

Think of a coffee shop: the cashier takes your order and serves the next customer while the barista makes your drink. You wait, but the line keeps moving. Similarly, an event producer can move on while a consumer processes the event later. Asynchronous processing creates a gap that the system must be designed to handle. section 7.3.2 section 7.9

Figure 7.6 Synchronous systems block the line (the CPU) until the work is done. Asynchronous systems take the order and promise to do the work later.

Compare a line blocked by synchronous work with an order accepted for later processing. section 7.3.2

The tradeoff is useful, not free: a producer may keep accepting orders while a consumer is unavailable, but readers can see stale data. A broker buffers messages during consumer outages. Eventual consistency does not mean a system can never fail, and asynchronous communication alone does not guarantee convergence. section 7.3.4 section 7.9

Choose the consistency requirement by consequence:

  • A social-media like count can often tolerate a delay. section 7.3.2
  • A checking balance or inventory count needs more care: stale data can permit an unacceptable result. section 7.3.2 section 8.2.2
  • If writes are accepted during a network partition, plan recovery. A saga can use compensating transactions to correct mistakes after the partition heals. section 7.3.5

CAP frames the consistency and availability choice during a network partition; PACELC also considers latency and consistency when the network is healthy. These are design tradeoffs, not a blanket instruction to make every part of a system eventually consistent. section 7.3.5 section 7.3.2

How Grokking Software Architecture covers it

How deep it goes
Defines convergence and explains operational tradeoffs through scenarios, while deferring detailed ACID and BASE rules.
Examples
Uses delayed shipping status, a coffee-shop queue, social-media likes, and financial balances to illustrate consistency choices.
What you can do after
Evaluate where delayed updates are acceptable and where stronger consistency or recovery planning is needed.
How it connects
Connects asynchronous communication, message brokers, BASE, CAP, PACELC, and compensating transactions.

Also explained in

Compare how 10 books explain eventual consistency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.