The law that decides what your database is allowed to promise when the network breaks.
In a distributed data store, when the network between nodes drops messages — a partition — you cannot simultaneously keep every read consistent (all nodes agree on the latest write) and keep the system available (every request gets a non-error answer). You must sacrifice one.
The name misleads people into "pick two of three." That is wrong. Partition tolerance is not a design choice — packets get dropped, cables get cut, switches reboot. P is a fact of the world. So the real theorem is much narrower and much more useful: during a partition, choose consistency or availability. When the network is healthy, you can have both.
Every read returns the most recent write, or an error. This is linearizability, not the "C" in ACID — it means the cluster behaves like one single copy of the data.
Every request to a non-failed node returns a non-error response — in bounded time. Note it says a response, not a correct one.
The system keeps operating when arbitrary messages between nodes are lost. Not optional in any real multi-machine deployment.
If Partition → choose A or C; Else (normal operation) → choose Latency or Consistency. This captures the daily trade-off CAP ignores.
x = 1. A client can write to either. So far, so good.x = 2 to N1. N1 cannot replicate it to N2. Now the two nodes disagree.x = 1 (chose availability, broke consistency) or refuse to answer until it can confirm with N1 (chose consistency, broke availability).| Choice | Behaviour under partition | Real systems |
|---|---|---|
| CP | Rejects or blocks writes on the minority side; needs quorum to proceed | etcd, ZooKeeper, HBase, Spanner |
| AP | Accepts reads and writes everywhere; reconciles later | Cassandra, DynamoDB, Riak, Couch |
| CA | Only coherent on a single node or a network that never partitions | A single-box RDBMS — not a distributed choice |
QUORUM reads and writes behaves CP-ish for that query; MongoDB with readConcern: local behaves AP-ish. The tuning knob is where the real engineering lives.x=2 to one side of a partition, then reads x from the other side. Describe exactly what a CP system does and what an AP system does — and what each one costs you.
Hint: one answer is an error or a hang; the other is a stale value plus a merge problem later.