Cruxly

Cruxly › System design › Foundations of Data Systems

CAP and PACELC, Precisely

the theorem behind the advice you were already given

Open the interactive lesson

Elsewhere in this track, the advice is: don't recite CAP, name the consistency guarantee and the staleness window instead. That advice only works if you actually understand CAP well enough to know when reciting it would be a mistake. This lesson is that understanding.

What CAP actually claims, precisely

CAP is not "pick two of three." The real claim: during a network partition, a distributed system must choose Consistency or Availability. Partition tolerance isn't a choice: networks will partition (a switch fails, a region loses connectivity, a cable gets cut). So: when partitioned, C or A.

TermPreciselyNot
ConsistencyLinearizability: every read sees the most recent write, as if there were one copy"Eventually correct"
AvailabilityEvery request to a non-failing node gets a response"The system is generally up"

CAP applies only during a partition and says nothing about normal operation. CP and AP systems still differ on a healthy network: Cassandra at consistency level ONE, or DynamoDB's default eventually consistent reads, can return stale data with no partition. That choice is PACELC's "else" branch (below), the more useful interview framework.

Why you mechanically cannot have all three

Derive it, don't quote it. A client writes to replica A. The update takes time to reach B, even on a healthy network, and indefinitely long during a partition. A second client reads B before it arrives:

B's choiceResultProperty lost
Answer from its stale copyThe read succeeds, with a wrong valueConsistency
Refuse until it can confirm it's currentCorrect, but no responseAvailability

No third option: B can't learn whether its copy is current without asking A, and the partition blocks exactly that. Partition tolerance isn't a third knob; it's what forces the choice.

PairMeaningExample
CANot partition-tolerantA single-node RDBMS: nothing to partition between
CPGives up availability under partitionBigTable, MongoDB (default config)
APGives up consistency under partitionCassandra, CouchDB

CA needs a system that can't partition. Replicate over an unreliable network and you're back to C or A.

CP versus AP, and what each actually looks like in production

Opposite answers to "what does the minority side do right now?"

During a partitionExamplesWhy
CPThe minority side stops accepting writesZooKeeper, etcd, the seat-booking exercise in this trackA stale seat count sells a seat twice. Consensus needs a majority so a minority can't make progress: the safety property, not a bug
APBoth sides accept writes, then reconcile: last-write-wins, app merge logic, or CRDTs (built to merge without conflict)Cassandra (default), the 2007 Dynamo paper, DynamoDB Global Tables in multi-Region eventual consistency mode (last-writer-wins)Shopping cart: "site down" is far worse than merging two carts after a blip

Today's DynamoDB isn't the Dynamo paper: within a region it uses a single leader per partition. Only Global Tables in multi-Region eventual consistency (MREC) mode are AP. Since June 2025 Global Tables can instead run in multi-Region strong consistency (MRSC) mode, which reads the latest data from any Region.

:::key The one-sentence test Does a wrong answer cost more than an unavailable one? Money and inventory: yes, be CP. A follower count or a "you might also like" list: no, be AP. :::

Label each piece of state, not the system: e-commerce is typically CP for inventory and payment, AP for the catalogue and recommendations.

PACELC — the framework that covers the other 99.9% of the time

CAP covers the partition. PACELC covers the rest of the time.

:::key The full statement, and the half nobody quotes If Partitioned, choose Availability or Consistency. Else, choose Latency or Consistency.

Synchronous replication waits for replica acks: every write pays latency, partition or not. Asynchronous replication returns immediately: a reader on a lagging replica sees stale data, no partition required. :::

So "my system is CP" says nothing about the trade paid on every normal write.

SystemUnder partitionNormal operation
DynamoDB, single regionWrites go through a per-partition leaderEL for default (eventually consistent) reads; strongly consistent reads are opt-in
DynamoDB Global Tables, MREC modeAP — regions accept writes independentlyEL — cross-region replication is asynchronous, last-writer-wins
DynamoDB Global Tables, MRSC mode (since June 2025)Strongly consistent across Regions, recovery point objective of zeroEC — replication is synchronous, so consistency is chosen over latency
MongoDB (default settings)CP for majority-acknowledged writesNot EC by default: the default read concern can return data later rolled back; readConcern: "linearizable" (or majority) buys consistency at a latency cost
Cassandra (tunable)APtunable EL or EC per query, via consistency level
SQL primary + async replicasCP for the primary itselfEC on the primary; EL on replicas — and an async failover can lose acknowledged writes

Tunable stores answer the trade per query: with Cassandra you pick latency or consistency per read via the consistency level, not once for the system.

Using this correctly in an interview, not just knowing it

"Don't recite CAP" doesn't mean avoid it. Speak one level more precisely than the theorem.

AnswerWhy
Weak"I'd go with AP for availability."Nothing about normal operation (99.9% of the system's life) or which data
Strong"Order status is CP: a partition should refuse rather than show a wrong state, and I've sized the blast radius to one partition of orders. Product search is AP: async replication for low write latency, converging within about two seconds, and during a partition slightly stale results beat an error page."Names the data, both choices (C or A, L or C), the staleness number, and why the trade fits that data

:::warn The failure mode this lesson exists to prevent Reciting "pick two of three" is worse than not mentioning CAP: it signals reading, not understanding, and an interviewer who knows the real claim notices. Precision is the signal. :::

How to say it in the interview

"CAP is a statement about ONE moment — a partition is happening right now, what do you do. PACELC is the more useful half nobody quotes: even with no partition at all, you are still choosing between latency and consistency, every single request."

Checklist

Practice this interactively
Share this lessonWhatsAppLinkedInX

Related lessons