CAP Theorem
What is it?
The CAP theorem says that when a distributed system's network is partitioned, it must choose between staying consistent and staying available — it can't fully guarantee both.
Explain like I'm 5
Why was it created?
It was formulated to clarify a real, unavoidable trade-off engineers face when designing distributed data systems.
Where is it used?
- Choosing/configuring distributed databases
- Designing multi-region systems
- Reasoning about failure behavior
- System-design interviews
Why should developers care?
It explains why distributed databases behave the way they do and guides design decisions, making it a staple of senior system-design discussions.
How does it work?
CAP names three properties: Consistency (everyone sees the latest data), Availability (every request gets a response), and Partition tolerance (the system works despite dropped network links). Since partitions can always happen, you must trade consistency against availability during one.
Real-world example
During a network split, a banking system may refuse some writes to stay consistent, while a social feed may keep accepting writes and reconcile differences later.
Common use cases
- Selecting a database for a workload
- Designing for network failures
- Explaining eventual consistency
- Architecting multi-region data
Advantages
- Clarifies an unavoidable trade-off
- Guides database choice
- Frames failure-mode design
- Common shared vocabulary
Disadvantages
- Often oversimplified
- Says nothing about normal (non-partition) operation
- Real systems are more nuanced than three letters
When should you use it?
When reasoning about how a distributed data system should behave during network failures.
When should you avoid it?
As a strict rulebook — it's a guide, not a full description of system behavior.
Alternatives
Related terms
Interview questions
Beginner
- What do C, A, and P stand for?
- Why can't you have all three during a partition?
Intermediate
- What is a network partition?
- Give an example of choosing availability over consistency.
Senior
- How does PACELC extend CAP?
- How would CAP influence your database choice for a use case?
Common misconceptions
- "You must pick two of three at all times" — the trade-off only forces a choice during a partition.
- "CAP describes everyday performance" — it's about behavior when the network splits, not normal operation.
Fun facts
- The 'partition tolerance' part isn't really optional for real distributed systems — networks fail.
- PACELC adds: even without partitions, there's a latency-versus-consistency trade-off.
Timeline
- 2000 — CAP conjecture proposed by Eric Brewer
Learning resources
Quick summary
The CAP theorem states a distributed system must trade consistency against availability when the network partitions, since partitions are unavoidable.
Cheat sheet
- Consistency, Availability, Partition tolerance
- Partitions are unavoidable
- During a partition: pick C or A
- PACELC adds latency trade-offs