Back
LearnSystem Design PlaybookCAP Theorem & Consistency

CAP Theorem & Consistency

2 min read

CAP, Consistency & Availability

The CAP theorem says a distributed data store can guarantee only two of these three during a network partition:

  • Consistency — every read sees the latest write.
  • Availability — every request gets a (non-error) response.
  • Partition tolerance — it keeps working despite dropped messages between nodes.

The real interpretation

Partitions will happen, so P is non-negotiable. The real choice is: during a partition, favour C or A?

Choice Behaviour during a partition Examples
CP Reject requests to stay consistent HBase, etcd, ZooKeeper
AP Answer with possibly stale data Cassandra, DynamoDB

A banking ledger picks CP (better to error than show a wrong balance). A social feed picks AP (better a slightly old feed than an error).

The consistency spectrum

It's not binary. Strongest to weakest:

  1. Strong / linearizable — reads always see the latest write.
  2. Read-your-own-writes — you see your own updates immediately.
  3. Causal — related events appear in order.
  4. Eventual — replicas converge eventually if writes stop.

PACELC — the fuller picture

CAP only covers partitions. PACELC adds: else (when the network is fine), you still trade Latency vs Consistency.

In an interview, always state your consistency choice explicitly and justify it from the product's needs.

Tip