Bookmarks

Eventual consistency

A consistency model in distributed systems: once new writes have stopped, every reader will in time see the latest version of the data.

Also: eventually consistent

checked 18 Nov

All terms

Strict consistency between replicas is expensive: every write has to wait for the replicas to acknowledge it. That is why large systems — from DNS to database replicas — often choose a different trade-off: the write is accepted straight away, and the changes spread across the replicas in the background. The term was popularised by Werner Vogels, Amazon’s chief technology officer, in a 2008 article for ACM Queue.

How it works

A write lands on one replica (or on a majority, depending on the protocol) and then spreads to the rest in the background. Until it arrives, a reader may get the old value; the time between the write and the moment when all readers are guaranteed to see the new one is called the inconsistency window. Once no new writes arrive, the replicas converge sooner or later: any read returns the latest version. The classic example is DNS: changes to a record spread across servers and caches, and until the TTL expires the client sees the old address.

GuaranteeWhat the reader sees
Strong consistencyalways the latest written version, even at the cost of availability and latency
Eventual consistencypossibly a stale version right after the write; the latest one once the replicas converge
Weak consistencya matter of luck: the update may never show up at all, and no guarantees are given

Flavours with guarantees

  • Read-your-writes (read-your-writes) — the author sees their own edit straight away.
  • Session consistency (session consistency) — the same guarantees, but only while the user’s session is alive.
  • Monotonic reads (monotonic reads) — once a reader has seen a newer value, they never go back to an older one.
  • Causal consistency (causal consistency) — the reader sees related updates in the order of their causes.

Where it shows up

Asynchronous DBMS replicas work in exactly this way: a lagging replica may return stale data, but it catches up with the primary. In DynamoDB, reads are eventually consistent by default, while the ConsistentRead=true option enables strongly consistent reads — at twice the cost. The developer decides for each operation whether strict freshness is needed: for example, the balance after a payment is shown only by a strongly consistent read, while comments can be served by any read.

Sources

the term is written from these pages

Verified 18 Nov

Not to be confused with

what it is mixed up with and how it differs

  • ACIDACID transaction properties

    ACID describes the consistency of transactions within a single database, while eventual consistency is the behaviour of replicas in a distributed system.

  • CAP theorem

    CAP explains why strict consistency and availability are incompatible under a network partition; eventual consistency is one of the trade-offs.

In depth in the references

where the topic is covered in detail