Search DistillSys

Find a concept

Type at least two characters to search lessons, designs, papers, and interview prep.

Consistencyfundamental5 min read

CAP Theorem

Understand what a network partition really forces you to choose—and what CAP does not say.

2–5 minute refresher
Mental model

Partition occurs → preserve one answer or preserve every response

30second
refresher

CAP says that when replicas cannot communicate, a distributed system cannot guarantee both a single consistent answer and a successful response from every reachable replica. It must choose per operation: reject or delay some work, or accept that answers may temporarily diverge.

What problem does CAP help us reason about?

Replicas normally coordinate over a network. Networks can delay, drop, or isolate messages while every machine appears healthy. Once two sides cannot communicate, neither can know whether the other side is down or merely unreachable.

CAP gives us language for the product decision hidden inside that uncertainty.

The three properties, plainly

  1. Consistency — every successful read behaves as if there were one up-to-date copy.
  2. Availability — every request reaching a healthy node receives a non-error response.
  3. Partition tolerance — the system continues with messages lost or delayed between groups of nodes.
Decision guide

Key trade-offs

ChoiceWhat you gainWhat it costs
CP during partitionOne authoritative answer and protected invariantsSome requests wait or fail
AP during partitionEvery reachable region can keep servingConflicts or stale reads must be reconciled
Per-operation policyGuarantees match business consequenceA more explicit application model

What happens if?

What happens if?

Two regions lose connectivity

If both regions accept updates to the same record, the service remains available but may create conflicting versions. If only the elected region accepts writes, the system preserves one order but users in the isolated region cannot complete that operation.

What happens if?

The network is merely slow, not broken

The system cannot distinguish delay from failure with certainty. A timeout converts uncertainty into policy: wait longer for stronger confidence, or respond sooner with weaker freshness.

Where this appears in real systems

Banking ledgers often reject writes without authoritative coordination. Shopping carts and social feeds frequently accept temporary divergence. Many databases let teams select consistency per request rather than declaring the whole product “CP” or “AP.”

Senior interview modeWhy is ‘pick any two of CAP’ misleading?Show answer

Because partition tolerance is a condition imposed by the network, not a steady-state feature to casually disable. Before a partition, a system can provide both consistency and availability. During one, it must decide which successful operations preserve a single truth and which remain responsive.

#cap#consistency#availability#partitions