Skip to content

Core system concepts · Concept lesson

Consistency

Specify what readers may observe after writes, compare consistency guarantees, and understand the CAP tradeoff during network partitions.

Written for readers who already know the basics. If the words here are new to you, read The request lifecycle and Capacity estimation first.

Original educational architecture · Version 2026-11-12.1 · Examples use stated hypothetical assumptions, not a company's actual design.

What you will be able to explain

  • Distinguish linearizable, sequential, and eventual consistency at a useful level.
  • Explain the CAP tradeoff specifically during a network partition.
  • Choose a consistency contract aligned with user-visible invariants.

How consistency is a contract

Consistency describes which histories of reads and writes a system permits. It is not a single slider and should be stated from the caller's point of view. Linearizability makes each operation appear to take effect at one instant between invocation and response and respects real-time ordering. Sequential consistency preserves a common operation order but need not preserve real-time order across clients. Eventual consistency allows temporary divergence, with convergence expected after updates stop and communication resumes. Session guarantees such as read-your-writes or monotonic reads can improve user experience without requiring every read to coordinate globally. A replicated system's behavior depends on write acknowledgement, replica visibility, and failure handling. Choose the weakest guarantee that still protects the business invariant and user expectations, because stronger coordination can increase latency or reduce availability in some failure conditions. Explain the guarantee using concrete operations, not just labels.

Write visibility across replicas
1. Client write

Submits a change and observes the acknowledgement contract.

2. Write authority

Orders or coordinates the accepted state change.

3. Replica

May expose the change after propagation.

4. Subsequent read

May be routed with session or consistency requirements.

5. Network partition

Separates nodes and forces a consistency/availability decision.

  1. Client write → Write authority: write request
  2. Write authority → Replica: replicate change
  3. Replica → Subsequent read: possibly delayed visibility
  4. Write authority → Subsequent read: coordinated read
  5. Network partition → Write authority: communication failure changes choices

Worked example: editing a profile

The same design needs an explicit rule when communication is interrupted. Suppose two regions cannot reach one another and both receive requests to claim the globally unique workspace name “team-north.” If each region confirms the claim independently, both responses may be successful locally but the global uniqueness invariant is broken. To preserve one linearizable ownership history during that partition, only the side that can reach or retain the designated authority can confirm the claim; the other side must reject, queue, or return an explicitly pending result. The latter region may still serve safe cached profile reads, if their freshness contract allows it. If the product instead accepts claims on both sides for availability, it must acknowledge that a conflict can occur and define a deterministic resolution, audit history, and user remediation. Once communication returns, exchanging updates does not magically decide whose claim wins. CAP's classic limit applies in this partition scenario: the system cannot promise both successful writes on both separated sides and a single linearizable global history. Outside a partition, the architecture still makes latency, coordination, and failure tradeoffs, but the slogan is not a permanent choice among three modes.

A user changes a profile name from “Ari” to “Ari K.” at time 10:00:00 and receives a successful response. At 10:00:00.050, a read from a lagging replica returns “Ari.” Under eventual consistency, this can be allowed briefly, but it violates a read-your-writes expectation if the same session sees the older value. Route that session's next read to the primary or carry a commit position and wait until the replica has applied it. If there are 3 replicas and each applies 900 updates/second while the primary generates 1,000, backlog grows by 100 updates/second on each lagging replica. The number is a rate, not a time bound: backlog age depends on later traffic and apply capacity. A profile display can often tolerate bounded staleness; access permissions or account balances generally need stronger coordination. Define a maximum stale interval only if the system can measure it and fail or route safely when it is exceeded.

Consistency choices

A strongly coordinated primary read is simple for a write-followed-by-read but may add network travel and limit operation during a partition. A session token can preserve read-your-writes while allowing ordinary reads elsewhere. Quorum reads and writes can overlap in some replication systems, but their exact guarantee depends on the system's versioning, failure, and conflict rules; a quorum count alone is not a universal proof of linearizability. CRDTs can converge for operations with suitable algebraic properties, such as set union, but not every business rule has a safe merge. Eventual projections suit search indexes and activity views when users accept delay and can see freshness. A cache introduces its own staleness policy. For each choice, define conflict resolution, monotonicity, and what happens under concurrent updates. Strong consistency for every field is often unnecessary; different data domains can make different tradeoffs if boundaries are explicit.

Failure and recovery

During normal operation, replication lag may be small; during a communication failure, replicas can no longer exchange reliable updates. Only in this network-partition setting does the CAP tradeoff state that a distributed data system cannot guarantee both a linearizable response for every request and successful responses from both separated sides. A design may reject or delay some operations to preserve a single consistent history, or accept operations on reachable sides and reconcile later, with possible conflicts. CAP does not say that systems choose only two of consistency, availability, and partition tolerance at all times; partition tolerance describes behavior when the partition occurs, and latency and failure choices remain nuanced. Recovery after communication returns requires catching up, resolving conflicting writes if accepted, and preventing stale leaders from overwriting newer state. Tell users whether an operation is rejected, pending, or potentially conflicted; do not silently claim a completed globally consistent update.

When weaker consistency is acceptable

Do not demand linearizable reads for every counter, timeline, or search suggestion when a short delay is harmless and strict coordination would cost more than the user benefit. Do not accept eventual consistency for a uniqueness or balance invariant merely because the datastore replicates quickly in ordinary tests. A user interface can tolerate a temporarily stale avatar but not two users receiving the same unique reservation. Avoid exposing a broad label such as “eventually consistent” without specifying expected lag, repair, and error behavior. Do not infer consistency guarantees from a vendor's marketing term; verify the exact operation and failure semantics in primary documentation. A single-writer database can still have stale caches and replicas. Choose consistency per invariant and access path, and provide clear behavior for uncertain writes. Stronger is not always better, weaker is not automatically scalable, and neither label substitutes for a correctness argument.

Senior followups

Ask what exact read and write histories are allowed, and whether the guarantee applies across clients, regions, and failover. Does a successful acknowledgement mean one node stored the write or a quorum persisted it? How does the system behave when a partition separates a client from the leader? Can clients distinguish stale, unavailable, and conflicted results? How are concurrent updates merged, rejected, or ordered? Is there a measurable staleness objective, and how does the caller respond when it is exceeded? Consider external side effects: a consistency guarantee in one database does not guarantee a payment provider or cache observes the same order. Review session tokens, version numbers, and conflict UX. The senior task is to translate product language (“immediately visible,” “never duplicate”) into operation-level guarantees and tests, then state costs and failure behavior without overpromising.

Operational practice

Test consistency with concurrent clients and controlled network delays, not only sequential unit tests. Verify read-your-writes after primary failover and after a client switches replicas. Track replication lag, rejected writes, conflict resolution, and stale-read rates using bounded labels. Use versioned responses when the client needs to detect an older representation. A status that says “saved” should mean the guarantee promised by the API, not merely that one process accepted input. For eventually consistent views, show freshness when useful and provide a refresh path that does not overwhelm the origin. During incidents, communicate which operations are safe and whether accepted writes may need reconciliation. Keep a testable invariant catalog: uniqueness, monotonic counters, ownership changes, and visibility timing. Observed low lag is not a substitute for a contract; lag can grow under load or failure.

Terms in plain language

Linearizability
A guarantee that each operation appears instantaneous between call and response while respecting real-time order.
Eventual consistency
A convergence property: if updates stop and communication recovers, replicas eventually reflect a common state.
Network partition
A communication failure that divides nodes into groups unable to reliably communicate with one another.
Read-your-writes
A session guarantee that a client sees its own successful writes in later reads.

Preparing practice controls…

Check your understanding

These checks explain concepts. They do not measure architecture seniority or update readiness.

1. When does the CAP consistency-versus-availability tradeoff become relevant in its classic form?
2. Which example is often a reasonable candidate for bounded eventual consistency?

Design independently

A global collaboration app wants to make profile edits quickly visible while preserving uniqueness of workspace names. Specify different consistency expectations for these two data types and explain behavior during a network partition.

Hints, not a solution
  • A profile display and a unique name have different consequences.
  • Discuss the partition case rather than treating CAP as an always-on choice.
  • Make conflict and recovery behavior visible to users.

0 / 20,000 characters · Not saved

Your learning notes

Sign in to save

Marking a lesson read and reviewing an exercise are separate actions. Neither implies mastery. Saved work is account-owned; saves are explicit and do not queue offline.

References and boundaries

Primary documentation supports the mechanisms described. It does not certify these hypothetical architectures, prices or sizing assumptions. Review platform-specific behavior before implementation.

Amazon Dynamo paper

Primary system paper discussing eventual consistency and availability tradeoffs.

Back to curriculum