liveBook · Manning

Consistency model

As explained in Latency

A consistency model is a set of guarantees defining the ordering and visibility of operations and data updates in a distributed system.

A consistency model defines how a distributed system orders operations and when updates become visible across replicated copies. Replication therefore requires a choice between latency, consistency, and availability: stale reads may be acceptable for faster responses, while applications needing the latest data may accept slower reads. section 4.3

Common models occupy different points between strict global ordering and weak visibility guarantees:

  • Linearizability provides the strongest ordering, while eventual consistency provides the weakest; causal and session consistency occupy intermediate positions. section 4.3.3
  • Causal consistency preserves the order of causally dependent operations but makes no ordering promise for concurrent operations. Vector clocks can track these causal relationships. section 4.3.3
  • Session consistency provides monotonic reads and read-your-writes within one user session, without requiring immediate visibility to other users. section 4.3.3

Collaborative document editing

If user A writes “Hello” and user B observes it before writing “world,” causal consistency ensures other users observe “Hello” before “world.” A concurrent “Goodbye” update may appear before or after that dependent sequence. section 4.3.3

Figure 8.2 Example use of acquire and release memory barriers to ensure the ordering between writes to two variables, data and flag, where it’s critical that the write to data is visible when the write to flag becomes visible. In this example specifically, the flag indicates that some operation is done, where the result of the operation is stored in data. If we allow the write to flag to be visible before the write to data, the process could read invalid or stale data from data.
Figure 8.2: Example usage of acquire/release memory barriers.

Acquire and release barriers preserve visibility ordering between related writes, such as publishing data before setting a completion flag. This connects consistency guarantees to shared-memory implementation. section 8.4.1

How Latency covers it

How deep it goes
Defines distributed models, trade-offs, examples, and implementation mechanisms, then connects them to hardware memory ordering.
Examples
Uses collaborative document editing, shopping carts, vector clocks, and data-plus-flag publication ordering.
What it assumes
Assumes distributed replication and introduces visibility, ordering, causal dependence, and session guarantees through examples.
What you can do after
Evaluate consistency choices against application needs for latency, stale reads, ordering, and availability.
How it connects
Connects replication, linearizability, eventual consistency, causal consistency, session consistency, vector clocks, and memory barriers.

Also explained in

Compare how 4 books explain consistency model →

Related concepts

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