Skip to content

Consistency: What Replicas Promise and the CAP/PACELC Trade-offs

13 min reading

Specify permitted read histories and conflict behavior before choosing replica coordination.

Page details

Distribute the data · Lesson 07

Published · Sources · 13 min reading · Last edited:

Know first: Numbers Every Engineer Should Know; Reading Architecture Diagrams.

Editorial correction:

Earlier design notes used unsupported universal performance or reliability claims. This revision explains conditional mechanisms and explicitly hypothetical examples; no author-run benchmark or production incident is asserted.

More
20px

Northwind: Consistency: read histories, sessions and partitions

Outcome. After this lesson, you can make the address promise observable.

Hypothetical scenario. At Northwind, Priya reads an old address from a lagging support replica.

In short. Specify which reads require the latest confirmed write. Separate stale display reads from critical account changes.

The same item can have different observations

Hypothetical scenario. A seller withdraws a catalogue item and receives confirmation. A buyer subsequently opens the item through another region and still sees it as available. The reader's question is not whether the database has a fashionable consistency label. It is whether this observation is allowed by the service's contract.

The earlier data lessons established authoritative records, derived views and asynchronous work. Distributing those records creates multiple observers and communication delays. Consistency describes which histories of operations and observations are permitted, while durability asks what accepted state survives a failure. Those questions are related but different.

This lesson defines the requirement at the operation boundary, examines partitions and quorum arithmetic, and explains why clocks do not automatically establish a meaningful global order.

A product label does not specify every read

A system can offer different contracts for different operations. A reservation decision may need authoritative coordination, while an item description can permit a bounded or disclosed delay. A relational data model does not by itself make every replica read current, and a document model does not prohibit stronger coordination.

Likewise, “eventual” is not a freshness deadline. It needs assumptions about communication, successful propagation and conflict handling. If the business needs a particular visibility bound or read-your-writes behavior, state and implement it instead of substituting a general label.

Application caches and derived projections also belong in the observed path. A current database read cannot make a previously cached response current unless the cache policy and read path actually use that evidence. Specify the end-to-end operation the user receives.

Describe the history the user may observe

A linearizable operation behaves as though it took effect at a point between invocation and response, preserving the order of non-overlapping operations. For a register-like value, a read beginning after a completed write cannot simply return an older value unless another permitted operation explains the result.

A completed write before a later readA write of withdrawn completes. A later read begins on a lagging replica and returns available. The example asks whether that history is permitted by the declared contract, rather than assuming replica placement determines correctness.Write withdrawn → doneLater read → available?Which histories does this operation promise to exclude?

Session guarantees answer narrower questions, such as whether a client observes its own accepted write. Transactions introduce further constraints across operations and records. Do not treat a useful session guarantee as equivalent to a globally linearizable multi-record transaction.

The practical specification should name the operation, its state and observers, and the failure conditions under which it may wait, reject or return a weaker result. An explicit unavailable response can be more truthful than a result that silently violates the promised invariant.

Make the address promise observable

Priya's support screen and the checkout service can disagree about a recently changed address because they observe different copies at different points in replication. The customer-facing question is not whether the storage product is described as consistent. It is whether a completed change must be visible to this later read, and what the application does when the required observation cannot currently be obtained.

In a hypothetical history, a customer changes address A to B and receives success. A later support read begins after that success. Returning A violates a linearizable single-address contract even if the replica converges to B later. If the contract instead permits a bounded or explicitly signaled stale view, the interface must expose that choice honestly. A label such as eventual consistency does not define the permitted duration, the read-your-writes behavior or conflict handling by itself.

A quorum calculation is a useful starting point, not a complete storage protocol. With three members, a read set of two and a write set of two must overlap because 2 + 2 > 3. The overlapping member still needs enough version information and a defined read algorithm. Concurrent writes, membership changes and partial acknowledgements all affect what can be concluded from a response. Adding the set sizes is not a proof of linearizability.

Keep time and ordering separate. A timestamp can help identify a version under a particular model, but a larger wall-clock value does not make an unauthorized overwrite valid. CAP addresses the choices available during a communication partition; PACELC draws attention to latency and consistency choices outside that condition as well. Explain the chosen observation behavior for each operation rather than promising one universal setting for the whole application.

Work through a history and a quorum

Hypothetical scenario. Start with a stored quantity of seven. A write changes it to nine and completes at a chosen timeline position of 20 ms. A read starts at 30 ms and returns seven at 40 ms, with no intervening write. Because the write completed before the read began, that result violates a linearizable single-value contract. The times specify this illustrative history; production clocks do not automatically provide such a shared timeline.

If the operations overlap instead, their invocation order alone does not force the same conclusion. Determine whether there is a permitted placement of their effects within the overlapping intervals. This is why a trace showing an earlier start is not sufficient evidence of an ordering violation.

For a separate quorum example, choose three fixed replicas, require two acknowledgements for a write and read from two replicas. Any two-member write set and two-member read set within the same three members intersect because 2 + 2 > 3. The minimum intersection size is 2 + 2 − 3 = 1.

That set arithmetic does not, by itself, prove linearizability. The design must also establish accepted versions, how a reader chooses or repairs values, ordering of concurrent writes, membership changes and what an acknowledgement means. An intersecting reader can contact a replica without automatically recognizing the correct result.

If one of the fixed three replicas becomes unreachable, two can still form the chosen quorum; if only one remains reachable, they cannot. These are membership counts under the stated model, not a complete availability or data-loss prediction.

A history makes the difference between linearizability and sequential consistency visible. Both constrain possible observations. Linearizability additionally preserves the real-time order of nonoverlapping operations. Sequential consistency preserves each client's program order while allowing a global order that differs from real-time precedence between clients.

Hypothetical history: a write completes before another client's read
Chosen timeClient AClient B
10Invoke set(status = withdrawn)—
20Receive completion—
30—Invoke read(status)
40—Return available

With an initial value of available and no other operations, linearizability rejects that result: the completed withdrawal must precede B's read. Sequential consistency alone can place B's read before A's write because neither client's own program order is reversed. This example uses distinct clients. If A writes and then reads in its own program order, sequential consistency must respect that order too.

Read-your-writes is a session guarantee about observing the session's earlier writes. It does not establish a global real-time order for every other client. Sticky routing to an up-to-date owner or a required version carried with the session are possible implementation approaches, but each needs a contract for failover. Sending a session to an arbitrary lagging replica after recovery can lose the very guarantee the routing policy was meant to provide.

Eventual consistency describes convergence under suitable conditions when updates stop; by itself it does not bound how soon a particular reader sees a write. During a partition, a read requiring a current authoritative status may have to wait or report unavailable. A separately declared descriptive view can permit stale data. Name the operation and guarantee rather than assigning one adjective to the entire application.

Apply this to the payment case: a session seeing its own “payment submitted” value is not evidence that a provider confirmed capture. In the chat case, a remembered cursor does not authorize reading history after membership revocation. Observation order, external evidence and access control are related design concerns with separate requirements.

In the wild: Make the address promise observable

The primary reference establishes this concrete distinction: cAP concerns atomic behavior and availability under unreliable communication.

Partitions force a specific choice

The primary paper Perspectives on the CAP Theorem discusses the conflict between atomic read/write behavior and responding to every request under unreliable communication. This is not a catalogue of three independent features from which a database permanently picks two.

When regions cannot coordinate, state which operations may continue locally and which must reject or wait. A system may permit browsing stale descriptions while refusing conflicting reservations. Different operations have different consequences; a single CP/AP label hides those decisions.

Even without a partition, coordination has a latency and resource cost. Choosing a nearby replica or waiting for remote evidence can change the normal read path. Evaluate that trade separately from the exceptional inability to communicate; a fast healthy demonstration does not establish a partition contract.

The reconnected region overwrites a withdrawal

Hypothetical scenario. Two disconnected regions accept item updates. One withdraws the item, while another changes its description based on an older available version. On reconnect, the system uses a coarse wall-clock comparison and replaces the withdrawn state with the later-looking description update.

The problem is the conflict rule and the accepted operation semantics. A field merge, an explicit state machine or rejecting a conflicting operation can give a different outcome. None is universally right: decide whether withdrawal is reversible and who may change it. A physical timestamp should not silently determine a business rule.

Recovery needs evidence of what each region accepted and how readers should interpret the merged result. Replicating the chosen outcome afterward can distribute a mistake very reliably. Agreement about a state does not establish that the state satisfies the intended application policy.

Clocks and consistency are not synonyms

Lamport's logical-clock paper defines an ordering consistent with causal precedence. If one event happens before another in that relation, its logical timestamp is smaller. The converse does not hold: smaller logical timestamps alone do not prove causation. Physical time, causal order and a chosen total order answer different questions.

“A majority means every client sees the latest state.” Majority intersection is one ingredient; the read and write algorithms still need a correctness argument.

“Consistency means every accepted business action is valid.” A consistent database can preserve a transaction whose business rule was wrong.

“Once communication recovers, every conflict has an obvious winner.” The system needs a declared conflict and reconciliation policy, including cases that require an explicit decision.

Choose the smallest sufficient observation contract

Use stronger coordination when the operation's invariant requires it and the system can expose its availability and latency consequences. Use weaker observation contracts where the user can tolerate and understand them, with concrete rules for updates and conflicts.

Do not weaken a reservation's correctness silently to keep a health dashboard green. Nor should every page read incur global coordination simply because another operation requires it. Identify the state and guarantee that each operation actually needs.

The partitioning lesson next distributes ownership of keys. Carry these contracts forward: changing where a key lives or routing a read to another owner must not accidentally weaken the semantics already promised to its callers.

Limits of this model

Quorum arithmetic describes set overlap under fixed membership. It leaves the actual read/write protocol, conflict rules and progress assumptions to be specified. Time bounds require suitable clock and network assumptions; a consistency label does not establish every end-to-end behavior of an application.

Check yourself: inspect the history

A read begins after an acknowledged withdrawal and returns available. Is a region-local cache an adequate explanation under a linearizable item-status contract?

It explains how the violation might occur, not why it is allowed. The end-to-end read path must satisfy the promised observation contract or report a permitted unavailable outcome.

Two read replicas intersect two write replicas among three members. Is that the complete proof?

No. Version selection, concurrent operations, membership and acknowledgement semantics remain necessary. Set intersection is not the whole algorithm.

One event has logical timestamp ten and another eleven. Must the first have caused the second?

No. The logical-clock implication runs from causal precedence to increasing timestamps, not from every timestamp comparison to causation.

Northwind decision log

Specify which reads require the latest confirmed write.
Separate stale display reads from critical account changes.
Return unavailability when the stronger promise cannot hold.

Go deeper: Make the address promise observable

Related blog: Embedding migrations and compatible read views.