liveBook · Manning

Consistency model

As explained in The Coder Cafe

A consistency model is a specification of the ordering and visibility guarantees that a distributed system provides for operations on replicated data.

A consistency model specifies what clients can expect to observe when they read and write data held on multiple replicas. It matters because a write accepted by one node does not automatically appear to every client at the same time. The central questions are order—which operations users see first—and visibility—when a change becomes visible. section 6.7

Two people edit one document

Alice adds a paragraph to a shared document. Shortly afterward, Bob changes another paragraph. Will everyone see Alice’s addition before Bob’s change? Will Bob see Alice’s addition immediately, or only after a delay? A consistency model tells clients which observations the system permits; it does not describe the edits themselves. section 6.7

Consistency guarantees vary in strength:

  • Linearizability is the strong end described here: users see updates in the same order, with changes immediately visible to them despite replication. section 6.7
  • Weaker models can permit delays in visibility or temporary differences in observed order. Eventual consistency is an example. section 6.7

Stronger guarantees carry a cost: coordinating copies of data adds overhead and can slow performance. Network partitions sharpen the trade-off between consistency and availability; even without a partition, consistency can compete with latency. Choose guarantees by asking what the application’s users may safely observe, rather than assuming every database makes the same promise. section 6.7 section 6.15

Keep three related ideas separate. Consensus concerns what distributed nodes agree on and can support strong consistency; a consistency model concerns what clients may observe. Isolation levels concern interactions between concurrent transactions. And ACID consistency concerns data integrity rules, not the visibility of updates across replicas. section 6.6 section 6.1.1

How The Coder Cafe covers it

How deep it goes
Defines order and visibility and contrasts strong and weak guarantees through an example, without detailing an implementation procedure.
Examples
Uses two people editing a shared document to test whether updates appear in the same order and without delay.
What it assumes
Introduces replicas and concurrent access explicitly while relying on familiar database reads and writes.
What you can do after
Evaluate/understand it by asking which writes clients can see, in what order, and at what performance cost.
How it connects
Connects consistency models to consensus, isolation levels, ACID consistency, CAP, and PACELC while distinguishing their roles.

Also explained in

Compare how 7 books explain consistency model →

Related concepts

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