CAP Theorem states that a distributed system can guarantee at most two of three properties: Consistency, Availability, and Partition tolerance. In practice, since network partitions are unavoidable, you're always choosing between consistency and availability.
Every read receives the most recent write or an error. After a write completes, all subsequent reads see that write — regardless of which node they hit.
Example: You transfer $100. After the transfer completes, any query to any node shows the updated balance.
Every request receives a response (not an error), even if it's not the most recent data. The system is always up and responding.
Example: Even if some nodes are unreachable, the system still serves reads — potentially with slightly stale data.
The system continues to operate despite network partitions (nodes can't communicate with each other).
Example: If the network link between two data centers breaks, each data center continues to serve requests independently.
In any distributed system (multiple machines communicating over a network), network partitions will happen. You cannot build a distributed system without P.
Therefore, the real choice is: CP or AP?
Best for: Financial transactions, inventory management, any system where stale data could cause real-world harm
Best for: Social media feeds, shopping carts, recommendation engines, any system where a slightly stale read is acceptable
CAP only describes behavior during partitions. PACELC extends it:
"If there's a Partition (P), choose between Availability (A) and Consistency (C). Else (E), choose between Latency (L) and Consistency (C)."
This captures a key real-world trade-off: even without partitions, achieving strong consistency requires coordination (slower latency) vs. accepting eventual consistency (faster).
Consistency isn't binary. There's a spectrum:
| Model | Guarantee | Examples | |---|---|---| | Strong/Linearizable | Reads always see the latest write | etcd, Spanner | | Sequential | Operations appear in some global order | Zookeeper | | Causal | Causally related ops are ordered | Cosmos DB | | Eventual | Replicas will converge — eventually | Cassandra, DynamoDB |