Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Data-centric consistency models

Data-centric consistency models define correctness rules for replicated data in distributed systems, giving engineers formal guarantees about what values reads may return under concurrent updates and replica delays.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

When building distributed storage, caches or replicated services an engineer must choose a consistency model to balance correctness, latency and availability. Data-centric consistency models tell you what read operations are allowed to return after concurrent writes and how replicas must converge — this directly impacts API contracts, testing, and failure handling.

Key ideas

Start with basic words.

  • Replica: a copy of some data item stored at a node. Define before use.
  • Operation: a read or write performed by a process (client or server) on a data item.
  • History: a sequence of operation invocations and responses observed in the system.
  • Program order: the order in which operations are invoked by a single process.
  • Real-time order: if operation A completes (response) before operation B starts (invocation) in real time, then A precedes B in real-time order.
  • Legal sequential history: a sequence of complete operations on a data item where each read returns the value written by the most recent preceding write in that sequence (for registers).

Main data-centric models (defined precisely):

  1. Strict consistency (definition): the value returned by any read is the value of the most recent write in real (global) time. Assumption: a global real-time clock or instantaneous propagation. Exact statement: for any two operations w (write) and r (read), if w completes before r starts in real time, then r must return the value written by w or by a later write. This model is usually impossible to implement in a distributed system with network delays; it is only useful as an ideal.

  2. Sequential consistency (Lamport, 1979) (definition): A system is sequentially consistent if the result of any execution is the same as if the operations of all processes were executed in some sequential order, and the operations of each individual process appear in this sequence in the order specified by its program. Formal assumptions: no requirement to preserve real-time order between different processes. Exact statement to write in an exam:

  • Given a history H of operations by multiple processes, there exists a permutation S of the operations in H that (1) is a legal sequential history and (2) preserves the program order of each process.
  1. Linearizability (Herlihy & Wing, 1990) (definition): Linearizability is like sequential consistency but stronger: each operation must appear to take effect atomically at a single point (a linearization point) between its invocation and response, and real-time order must be preserved. Exact statement:
  • For any execution history H, there exists a legal sequential history S that (1) is equivalent to H (contains the same operations) and (2) respects the real-time order: if operation A completes before B starts in real time, then A comes before B in S.

Implication: Linearizability implies sequential consistency because preserving real-time order (a stricter requirement) ensures there is a sequential interleaving that also preserves program order. Also, linearizability is compositional (if each object is linearizable, the whole system is linearizable), whereas sequential consistency is not compositional.

  1. Causal consistency (definition): If an operation B is causally dependent on operation A (for example, B reads a value written by A, or was invoked after A in the same process), then all processes must observe A before B. Operations that are concurrent (no causal relation) may be observed in different orders at different processes. Use the happens-before relation → (Lamport): A → B when A and B are ordered by program order or when A is message-send and B is the receive caused by that message; closure by transitivity. Exact statement: a system is causally consistent if for all processes, reads see values that respect the happens-before partial order.

  2. PRAM (FIFO) consistency (definition): Writes from a single process are observed by all processes in the order issued by that writer, but writes from different processes may be seen in different orders. Also called FIFO per writer.

  3. Eventual consistency (definition): If no new updates are made to a data item, eventually all replicas will converge to the same value. No guarantees about intermediate reads. Often used with conflict-resolution policies (e.g., last-writer-wins) or CRDTs (Conflict-Free Replicated Data Types). Assumption: reliable message delivery eventually and no permanent partitions.

  4. Client-centric guarantees (bridging terms): For a single client interacting with replicas, there are useful guarantees often used together with data-centric models (define briefly):

  • Monotonic reads: if a client has seen a value, it will not see an older value later.
  • Read-your-writes: a client’s reads will see its previous writes.
  • Monotonic writes: a client's writes are applied in order.
  • Writes-follow-reads: a client's write after a read will be ordered after the write that produced the read value.

Diagrams to draw (exam style):

  • For sequential vs linearizability: draw a time axis horizontally. For each process, draw its sequence of operations as labeled boxes above the axis with invocation and response times. Show two operations from different processes with non-overlapping intervals (A completes before B starts). Label a linearization point in the center of each operation box and show a sequential order respecting real-time for linearizability but an alternative order that preserves per-process program order for sequential consistency but violates real-time. Caption: "Illustrate a history that is sequentially consistent but not linearizable: show A completes before B starts but the chosen sequential order puts B before A (violates real-time) — allowed in sequential but not linearizable."

  • For causal consistency: draw processes P1, P2, P3; show P1 writes x=1; P2 reads x=1 then writes y=2; P3 must not see y=2 before seeing x=1.

Proof sketch (common exam derivation): Show linearizability ⇒ sequential consistency: start from linearizable history H, linearizability gives a legal sequential history S preserving real-time order; program order is a subset of real-time order for operations in the same process (under the standard assumption that each process issues at most one operation at a time, so each operation’s response precedes the next invocation), so S preserves program order; thus S satisfies the sequential consistency definition.

Assumptions and trade-offs:

  • Stronger models (linearizability, strict) require more coordination and hurt availability/latency under partitions. Refer to CAP theorem and consensus topics for deeper trade-offs.
  • Weaker models (eventual, causal) allow higher availability and partition tolerance but require application-level reasoning about anomalies.

Formulas

H is sequentially consistent ⇔ ∃ S: S is a legal sequential history ∧ S is a permutation of H ∧ ∀p, order_p(H) ⊆ order(S)

  • order_p(H): program order of process p. No units; applies to histories of read/write operations.

H is linearizable ⇔ ∃ S: S is a legal sequential history ∧ S is a permutation of H ∧ real_time_order(H) ⊆ order(S)

  • real_time_order(H): pair (A,B) if A.response_time < B.invocation_time.

A → B (happens-before): defined as the transitive closure of (1) program order, (2) message-send → message-receive, and (3) read-from edges (a write and a read that returns its value).

  • Applies when defining causal consistency.

Eventual consistency: if no updates after time T, then ∃ T' > T such that ∀ replicas r1,r2: state(r1, T') = state(r2, T').

  • Assumes eventual delivery and no further writes.

Worked examples

Example 1 — Sequential consistency trace (registers X and Y):

Given: two processes P1 and P2. Initial X=0, Y=0. Operations (in time order):

  1. P1: write X=1 (complete)
  2. P2: read X → r1 returns 1 (complete)
  3. P2: write Y=2 (complete)
  4. P1: read Y → r2 returns 0 (complete)

Question: Is this history sequentially consistent?

Steps:

  • Program orders: P1: write X then read Y; P2: read X then write Y.
  • Can we find a sequential S that (a) is legal and (b) preserves program order? Try order: P1.write(X=1), P2.read(X)→1, P2.write(Y=2), P1.read(Y)→2. But P1.read returned 0 in history, not 2, so this S does not match the observed responses.
  • Try alternative S: P2.read(X)→1, P1.write(X=1), P2.write(Y=2), P1.read(Y)→0. This violates program order for P1 (read after write must appear in that order).
  • In fact, a sequential order exists that preserves each process program order and matches the observed read values: P1.write(X=1), P2.read(X)→1, P1.read(Y)→0, P2.write(Y=2); therefore the history is sequentially consistent.

Answer: sequentially consistent. Explanation: One valid sequential order is P1.write(X=1) ; P2.read(X)→1 ; P1.read(Y)→0 ; P2.write(Y=2), which preserves each process’s program order and yields the observed returns.

Example 2 — Linearizability counterexample (real-time order violation):

Two processes P1, P2 operate on register R with initial 0.

  • At time 1: P1 invokes write(R, 1); completes at time 4.
  • At time 2: P2 invokes read(R); completes at time 3 and returns 0.

Here P2's read completed at time 3 before P1's write completed at time 4. For linearizability, since read completed before the write finished, read cannot return 1 written by P1. The observed return 0 is allowed. But if instead P2 had returned 1, that would still be linearizable because the operations overlap; a violation would occur only if the read completed before the write was invoked (non-overlapping), yet it returned 1.

Example 3 — Eventual consistency with two replicas:

Replicas A and B initially value v0. Client at A writes v1; due to partition, B stays v0. Later client at B writes v2 concurrently. When partition heals and replicas exchange updates with last-writer-wins based on timestamps, both converge to max(timestamp(v1), timestamp(v2)) — eventual convergence achieved. Show steps and final value depends on timestamps.

Note: CRDTs provide deterministic merge without external timestamps (mention as direction).

Common mistakes

  • Claiming eventual consistency gives any read guarantees — it only guarantees convergence in the absence of new updates.
  • Forgetting to require that the sequential history is legal (reads must return last written value in that sequence).
  • Assuming causal consistency prevents lost updates; it only constrains order for causally related operations.

For your exam

Question types you will see: definitions (state and compare models), short notes (differences, when to use), derivations/proofs (show linearizability ⇒ sequential consistency), trace problems (given a history, decide which models it satisfies), diagrams (draw histories and linearization points), and design questions (choose a model and justify for an application).

What full-mark answers include:

  • Precise definitions with bold naming and source (Lamport, Herlihy & Wing when asked).
  • Assumptions and consequences (availability, latency trade-offs; mention CAP/consensus briefly when relevant).
  • For trace problems: explicit program and real-time orders, attempt to construct a legal sequential history, show why possible/impossible step-by-step.
  • For proofs: use formal statements (existence of S) and show implication logically.

Quick check

  1. Which model requires preserving real-time order, sequential consistency or linearizability?
  2. What does eventual consistency guarantee if no new updates are made?
  3. In PRAM/FIFO consistency, what ordering guarantee is given?

Answers: 1) Linearizability. 2) All replicas eventually converge to the same state. 3) Writes from each single process are seen by all processes in the order issued by that writer (per-writer FIFO).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?