What CAP Theorem States
You'll learn: The three fundamental properties distributed systems must balance according to the CAP Theorem.
The Three Pillars of Distributed Systems
The CAP Theorem (also called Brewer's Theorem) states that any distributed database system can simultaneously guarantee at most two of these three properties:
1. Consistency (C)
Every read receives the most recent write or an error. All nodes see the same data at the same time. Think of it like a shared document where everyone always sees the exact same version—no outdated copies.
2. Availability (A)
Every request receives a response (success or failure), without guaranteeing it contains the most recent data. The system always answers, even if some nodes are down. Imagine a library that always gives you a book, even if it might not be the latest edition.
3. Partition Tolerance (P)
The system continues operating despite network failures that split nodes into groups that can't communicate. This is like branches of a store chain that must function even when phone lines go down between locations.
The Trade-off
When a network partition occurs (communication breaks between nodes), you must choose: wait for consistency (sacrificing availability) or respond immediately with potentially stale data (sacrificing consistency).
Since network failures are inevitable in distributed systems, Partition Tolerance is non-negotiable in practice. The real choice becomes CP vs AP:
- CP systems (like MongoDB with strict settings): Reject requests rather than serve stale data
- AP systems (like Cassandra with eventual consistency): Always respond, accepting temporary inconsistencies
Key Takeaway: The CAP Theorem proves distributed systems cannot simultaneously guarantee consistency, availability, and partition tolerance—you must pick two, and in practice, you choose between consistency or availability when partitions occur.