Cruxly › System design › Foundations of Data Systems
CAP and PACELC, Precisely
the theorem behind the advice you were already given
Open the interactive lessonElsewhere 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.
| Term | Precisely | Not |
|---|---|---|
| Consistency | Linearizability: every read sees the most recent write, as if there were one copy | "Eventually correct" |
| Availability | Every 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 choice | Result | Property lost |
|---|---|---|
| Answer from its stale copy | The read succeeds, with a wrong value | Consistency |
| Refuse until it can confirm it's current | Correct, but no response | Availability |
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.
| Pair | Meaning | Example |
|---|---|---|
| CA | Not partition-tolerant | A single-node RDBMS: nothing to partition between |
| CP | Gives up availability under partition | BigTable, MongoDB (default config) |
| AP | Gives up consistency under partition | Cassandra, 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 partition | Examples | Why | |
|---|---|---|---|
| CP | The minority side stops accepting writes | ZooKeeper, etcd, the seat-booking exercise in this track | A stale seat count sells a seat twice. Consensus needs a majority so a minority can't make progress: the safety property, not a bug |
| AP | Both 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.
| System | Under partition | Normal operation |
|---|---|---|
| DynamoDB, single region | Writes go through a per-partition leader | EL for default (eventually consistent) reads; strongly consistent reads are opt-in |
| DynamoDB Global Tables, MREC mode | AP — regions accept writes independently | EL — cross-region replication is asynchronous, last-writer-wins |
| DynamoDB Global Tables, MRSC mode (since June 2025) | Strongly consistent across Regions, recovery point objective of zero | EC — replication is synchronous, so consistency is chosen over latency |
| MongoDB (default settings) | CP for majority-acknowledged writes | Not 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) | AP | tunable EL or EC per query, via consistency level |
| SQL primary + async replicas | CP for the primary itself | EC 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.
| Answer | Why | |
|---|---|---|
| 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
- Stated CAP precisely: during a partition, choose C (linearizability) or A (every request served)
- Said CAP applies only during a partition and is silent about normal operation
- Derived, not just quoted, why you can't have all three
- Named a real system for each corner of the popularized CA/CP/AP triangle
- Used 'does a wrong answer cost more than an unavailable one' as the CP-vs-AP test
- Applied CP/AP per piece of data rather than labelling the whole system one way
- Extended to PACELC's else-branch: latency versus consistency with no partition at all
- Classified a real system on both axes (partition behaviour AND normal-operation behaviour)
- Named a tunable store's per-query consistency level as a real answer to the trade-off
- Gave the staleness window and the specific data it applies to, not just a C/A/P letter