System Design Fundamentals  /  CAP & Consistency
Fundamental 01~12 min readIntermediate
Deep Dive

The CAP theorem,
and the spectrum of consistency.

CAP is the most quoted and least understood idea in distributed systems. It's not "pick two of three" — it's a single forced choice that only matters in one specific moment. Here's what it really says, and the consistency models that live underneath it.

01

What CAP actually says

A distributed system tries to offer three things. Consistency — every read returns the most recent write (or an error). Availability — every request receives a non-error response, even if it isn't the latest. Partition tolerance — the system keeps working when the network drops or delays messages between nodes.

The theorem (Brewer's conjecture, proved by Gilbert & Lynch) says you can't have all three at the same time. But the framing "pick two of three" is misleading. In any real network, partitions will happen — cables fail, switches reboot, packets vanish. So partition tolerance isn't something you choose; it's something reality imposes. The actual decision is what to do during a partition: stay consistent, or stay available.

During a partition — you must pick one
CP

Consistency + Partition

Refuse or block requests that can't be confirmed correct. Some nodes go unavailable, but no one ever reads stale data.

AP

Availability + Partition

Answer every request from whatever replica is reachable, even if it's behind. Reconcile the divergence once the partition heals.

There is no "CA" column. A system that gives up partition tolerance is just a single node.
02

Why "CA" is a myth

People often label a single-node SQL database as "CA". That's only true because a single node can't be partitioned from itself. The moment you replicate that database across two machines to survive failure, you've entered the distributed world, and a partition between them forces the same CP-or-AP choice.

So the honest reading of CAP is: P is mandatory, and you trade C against A only when P strikes. When the network is healthy, a well-built system can deliver both strong consistency and high availability — CAP says nothing about the happy path. Which is exactly the gap PACELC fills.

→ Common interview trap

If you say "I'll build a CA system," a sharp interviewer will ask what happens when two replicas can't reach each other. Always frame your answer as CP or AP, and say which operations need which.

03

PACELC — the part CAP forgets

PACELC completes the picture: if there is a Partition, trade Availability vs Consistency; Else (normal operation), trade Latency vs Consistency. The insight is that consistency has a cost even with no failures: to guarantee a read sees the latest write, replicas must coordinate, and coordination takes round-trips. Lower latency means accepting weaker guarantees.

SystemOn partitionElse (normal)Classification
Dynamo / CassandraAvailabilityLatencyPA / EL
BigTable / HBaseConsistencyConsistencyPC / EC
MongoDB (default)ConsistencyLatencyPC / EL
SpannerConsistencyConsistencyPC / EC

Tunable stores (Cassandra, DynamoDB) let you slide this per-query by choosing how many replicas must respond — which connects directly to quorums and replication.

04

The consistency spectrum

"Consistency" isn't one thing. It's a ladder of guarantees, each weaker and cheaper than the one above.

From strongest (most coordination) to weakest (most available)
StrongestLinearizable — behaves like a single copy; every read sees the latest completed write, in real-time order.
Sequential — all nodes see operations in the same order, not necessarily real-time.
Causal — operations that depend on each other are seen in order; unrelated ones may differ.
Read-your-writes — you always see your own latest change (session guarantee).
Monotonic reads — you never see time go backwards across reads.
WeakestEventual — replicas converge if writes stop; reads may be stale meanwhile.

Pick the weakest model that still keeps your product correct. A bank balance needs linearizability. A "likes" counter is fine with eventual consistency. A chat app usually wants causal, so a reply never appears before the message it answers.

→ Mental model

Consistency is chosen per operation, not per system. The same database can require a linearizable write for an account balance and serve an eventually-consistent read for that account's activity feed.

05

Tunable consistency & quorums

Leaderless stores let you dial consistency at query time. With N replicas, a write waits for W acknowledgements and a read queries R replicas. If W + R > N, the read set and write set must overlap on at least one up-to-date replica, giving you strong consistency. Lower the numbers and you trade consistency for latency and availability.

Quorum trade-off (N = 3)

W=3, R=1  ·  W+R>N

  • Strongly consistent reads
  • Fast reads, slow writes
  • Write fails if any replica is down

W=1, R=1  ·  W+R≤N

  • Eventually consistent
  • Fast and highly available
  • Reads may be stale

This is the bridge between CAP and the physical mechanics of replication — and when you need a single agreed value rather than a tunable one, you've crossed into consensus.

Frequently asked

Quick answers

What is the CAP theorem?

During a network partition, a distributed system can guarantee either Consistency (every read returns the latest write) or Availability (every request gets a non-error response), but not both. Since partitions are unavoidable, the real choice is CP vs AP.

Why can't a system be CA?

Partition tolerance isn't optional — networks fail. A pure CA system only exists on a single node. Once partitioned, it must drop either availability or consistency, collapsing into CP or AP.

What is PACELC?

If Partition, trade Availability vs Consistency; Else, trade Latency vs Consistency. It captures that stronger consistency costs latency even when nothing has failed.

Strong vs eventual consistency?

Strong (linearizable) consistency means every read reflects the latest write, at the cost of coordination latency. Eventual consistency lets replicas disagree briefly but converge, trading freshness for speed and availability.

Finished this one? 0 / 12 Handbooks done