11 - CAP Theorem & Distributed Systems
Understanding CAP Theorem
The CAP Theorem states that a distributed data system can only guarantee two of the following three properties:
Plain text
┌─────────────────────────────────────────────────────────────┐
│ CAP Theorem │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ │
│ / C \ │
│ / Consistency \ │
│ / (All nodes see \ │
│ / same data at \ │
│ / same time) \ │
│ / \ │
│ └─────────────┬───────────────┘ │
│ / \ │
│ / \ │
│ / \ │
│ / \ │
│ / A \ │
│ / Available\ │
│ / (Every request \ │
│ / gets a response, \ │
│ / even if not latest) \ │
│ / \ │
│ └─────────────┬───────────────┘ │
│ / │
│ / │
│ / │
│ / P │
│ / Partition Tolerance │
│ / (System works despite │
│ / network failures) │
│ / │
│ │
│ In practice, you must choose CP or AP │
│ (You can't sacrifice partition tolerance in real systems) │
│ │
└─────────────────────────────────────────────────────────────┘