The CAP theorem is a fundamental concept in distributed systems that helps us understand the trade-offs involved in designing and managing databases. It states that in a distributed system, you can only guarantee two out of three properties at the same time:
Let’s break down each component, analyze why partition tolerance is unavoidable, and explore real-world implications.
In distributed systems, network partitions (e.g., dropped connections, server failures) are inevitable. Partition tolerance ensures the system continues operating even if nodes can’t communicate.
In CAP, consistency means strong consistency:
[Strong Consistency]
Node A (Latest Data: X=5) → Node B (Syncs to X=5)
Read from any node → Always X=5
Weak consistency (e.g., eventual consistency) is not what CAP refers to.
A database prioritizing availability will respond to every request, even with stale data during partitions.
[AP System During Partition]
Node A (X=5) ----✂️ Network Partition ---- Node B (X=4)
User reads Node B → Returns X=4 (stale but available)
No — they prioritize availability over strong consistency. Most use eventual consistency:
[Eventual Consistency]
Node A (X=5) → Syncs to Node B → Node B eventually becomes X=5
| Prioritize Consistency (CP) | Prioritize Availability (AP) |
|---|---|
| ✔️ Strong data accuracy | ✔️ 100% uptime |
| 🚫 Downtime during partitions | 🚫 Stale data during partitions |
| Use cases: Banking, inventory systems | Use cases: Social media, CDNs, IoT |
+---------------------+
| CAP Theorem |
+---------------------+
| 🟢 Consistency |
| 🔵 Availability |
| 🟠 Partition |
+---------------------+
Overlap Labels:
- CA: Rare (no real-world systems)
- CP: Strong consistency + partition tolerance
- AP: High availability + partition tolerance
Node A 🟢 (X=5) Node B 🔵 (X=4)
\ /
\ /
\ /
⚡💥⚡ (Network Partition)
CP System: Node B stops responding ❌
AP System: Node B serves stale data ⚠️
🔨 Build wisely: Use the CAP theorem to guide trade-offs, not as a strict rule.
Icons: