Course contentsShow
← Computer Science
Lesson 2604 of 2,87258. Distributed Systems BasicsFree lesson

The CAP Trade-off: Pick Two

Understanding why distributed systems can only guarantee two of the three CAP properties simultaneously.

The CAP Trade-off: Pick Two

What you'll learn: Why distributed systems must sacrifice one of the three CAP properties when network partitions occur.

The Impossible Trinity

The CAP theorem reveals a fundamental constraint: when a network partition happens, you cannot simultaneously maintain both consistency and availability. You must choose.

This doesn't mean you pick two properties and completely abandon the third. Rather, when the network splits (and it will), you face a binary decision:

The Choice During Partition

CP (Consistency + Partition Tolerance): Reject requests to maintain consistency. Some nodes become unavailable until the partition heals. You guarantee that all clients see the same data, but some get no response.

AP (Availability + Partition Tolerance): Accept requests even when nodes can't communicate. Every node responds, but they might return different (stale) data. You guarantee responses, but sacrifice consistency.

Why Not All Three?

During a partition, imagine two data centers lose connection. A write arrives at Data Center A. If you want consistency, Data Center B cannot serve reads until it confirms the write—but it can't reach A! To stay available, B must respond with potentially stale data, violating consistency.

There's no "CA" system in practice—networks will partition, making partition tolerance non-negotiable in distributed environments.

Real-World Examples

  • CP systems (e.g., distributed databases prioritizing correctness): Return errors during partitions rather than risk inconsistent data
  • AP systems (e.g., DNS, web caching): Always respond, accepting temporary inconsistencies

Key Takeaway: The CAP trade-off forces distributed systems to choose between consistency and availability during network partitions—you cannot have both simultaneously when the network fails.