🔺Key Takeaways
- 1CAP: during a network partition, you must choose between Consistency and Availability
- 2In practice, partitions are rare — PACELC is more useful: under normal conditions, trade off Latency vs Consistency
- 3Eventual consistency means all replicas converge given enough time — reads may be stale temporarily
- 4Strong consistency means every read returns the most recent write — simpler but slower
Understanding CAP
The CAP theorem states that a distributed system can provide at most two of three guarantees: Consistency (every read gets the most recent write), Availability (every request gets a response), and Partition tolerance (the system works despite network failures between nodes).
Since network partitions are inevitable in distributed systems, the real choice is between CP (consistent but may be unavailable during partitions) and AP (available but may return stale data during partitions).
CAP Theorem Visual
Consistency Models Spectrum
| Model | Guarantee | Performance | Use Case |
|---|---|---|---|
| Linearizable | Every read sees the latest write globally | Slowest (coordination required) | Banking, inventory with exact counts |
| Sequential | Operations appear in some total order | Moderate | Distributed locks |
| Causal | Causally related operations are ordered | Good | Social media feeds |
| Eventual | All replicas converge eventually | Fastest | DNS, product catalog, counters |
✅PACELC — The Practical CAP
PACELC extends CAP: during a Partition, choose A or C. Else (normal operation), choose Latency or Consistency. This is more useful because partitions are rare — most of the time you're trading latency for consistency. DynamoDB = PA/EL (available + low latency). Google Spanner = PC/EC (consistent always, accepts higher latency).
Advantages
- •Understanding CAP helps you make informed trade-off decisions
- •Different consistency models let you optimize per use case
- •AP systems achieve highest availability and throughput
Disadvantages
- •CAP is often oversimplified — real systems are nuanced
- •Eventual consistency makes application logic more complex
- •Strong consistency across regions adds significant latency
🧪 Test Your Understanding
Knowledge Check1/2
During a network partition, an AP system will: