CAP Theorem
Concept. CAP says a distributed database can guarantee at most two of Consistency, Availability, and Partition tolerance. Real networks partition, so Partition tolerance is mandatory. During a partition, each operation trades off Consistency against Availability.
Intuition. When a transatlantic cable cuts and Spotify's US and EU data centers can no longer talk, the system has to pick: either both regions stop accepting Premium upgrades until they reconnect (Consistency wins) or both keep taking writes that may conflict on reconnect (Availability wins). You don't get both during the partition; you only get to choose which one.
Pick Two
The network will partition
In a single program you can assume the network works. In a distributed system you cannot: links drop, packets vanish, and nodes split into groups that cannot talk. Partition tolerance is mandatory.
Figure 1. Partition tolerance is a given, not a choice. Consistency means every read sees the latest committed write. Availability means every request gets a response even when some nodes are unreachable. Partition tolerance means the system keeps operating when the network drops messages between groups of nodes. Real networks fail, so partition tolerance is mandatory (the green circle you always live inside), and during a partition your one choice is C or A: stay consistent and reject what you cannot verify (CP), or stay available and risk serving stale data until it reconciles (AP).
Real Systems: It's a Spectrum
A database is not permanently "CP" or "AP." A partition forces the choice between consistency and availability, and many systems let you set it per operation, so the same database can favor consistency for a payment and availability for a page view. Don't memorize the label. Ask what a system does when the network splits, and read its own documentation for the answer.
Key Takeaways
1. CAP is a model, not a law
CAP is a framework for reasoning about trade-offs under partition. Most systems offer tunable consistency levels. Use CAP to predict how a system behaves once a partition hits.
2. P is not optional
Network failures are a given. The decision is Consistency versus Availability. Design for partition tolerance first.
3. Choose based on requirements
Match the design to the business need. Financial systems demand Consistency. Social media favors Availability. Analytics tolerates stale data, so Availability wins there.