CAP and PACELC Theorems
What CAP really says (and what it does not), why PACELC is more useful day to day, and how real databases position themselves.
What it is
CAP theorem (Eric Brewer's conjecture in 2000, proved by Gilbert and Lynch in 2002): a distributed data store cannot simultaneously guarantee all three of:
- Consistency: linearizability, every read returns the most recent write.
- Availability: every request to a non-failing node receives a response.
- Partition tolerance: the system continues despite arbitrary message loss between nodes.
Because network partitions happen in any real distributed system, the practical reading is: during a partition, choose C or A.
PACELC (Daniel Abadi, 2010, published 2012) extends it: if Partition, choose A or C; Else (normal operation), choose Latency or Consistency. This captures the everyday cost of strong consistency: synchronous coordination adds latency on every write even when nothing is broken.
Try the CAP & PACELC Explorer to simulate a partition.
flowchart TD
Start{Network partition?}
Start -- Yes --> PA[Choose availability:<br/>accept writes on both sides,<br/>reconcile later]
Start -- Yes --> PC[Choose consistency:<br/>minority side rejects<br/>reads/writes]
Start -- No --> EL[Choose latency:<br/>async replication,<br/>local reads]
Start -- No --> EC[Choose consistency:<br/>synchronous / quorum<br/>coordination]Common misconceptions
| Misconception | Reality |
|---|---|
| "Pick any two of three" | You cannot drop P in a distributed system; the choice is C vs A during partitions |
| "CA databases" | A single-node database is not partition tolerant because it is not distributed; once replicated, it must choose |
| "Our system is CP, so it is always consistent" | Only for the operations and configuration that are actually CP (e.g. quorum reads) |
| CAP availability = high availability SLA | CAP availability is a strict formal property; real HA is about percentages |
Real-world positioning (default configurations)
| System | PACELC | Notes |
|---|---|---|
| Spanner | PC/EC | Paxos replication and TrueTime; strongly consistent globally |
| DynamoDB | PA/EL | Eventually consistent reads by default; strong reads per request in-region; global tables replicate asynchronously |
| Cassandra | PA/EL | Tunable; QUORUM read+write moves toward consistency at a latency cost |
| MongoDB | PC/EC with majority concerns | Configuration-dependent |
| etcd / ZooKeeper | PC/EC | Raft/ZAB consensus; minority partitions cannot write |
Real-world example
An airline seat inventory must never double-sell a seat: on partition, the minority side refuses bookings (PC). A flight status page prefers showing possibly stale data over an error (PA/EL), served from regional caches.
Advantages and disadvantages
| CP choice | AP choice |
|---|---|
| No conflicting writes, simple invariants | Always answers, survives partitions |
| Unavailable on the minority side during partitions | Conflicts must be resolved (LWW, CRDTs, app merges) |
| Higher write latency (EC) | Stale reads |
Architect-level considerations
[!ARCHITECT] Discuss CAP at the level of operations: "reserving a seat is CP; reading the seat map is AP". Mention PACELC to show you understand the latency cost even without failures.
Interview questions and answers
Is MySQL CP or AP?
A single MySQL server is not distributed, so CAP does not really apply. With asynchronous replicas and reads from replicas, it behaves AP/EL for reads (stale reads possible). With semi-synchronous replication or Group Replication in single-primary mode, it leans toward CP at a latency cost. The answer depends on configuration.
Why does PACELC matter more in practice than CAP?
Partitions are rare; latency is constant. Most design decisions (sync vs async replication, quorum reads, multi-region writes) are about the latency-consistency trade-off in normal operation.
How does Spanner claim to be "effectively CA"?
Google argues that its private network makes partitions so rare that availability is extremely high while keeping strong consistency. Technically it is CP: during a real partition, the minority cannot commit.