CAP Theorem

Dated Jun 6, 2026; last modified on Sat, 06 Jun 2026

Notes

The CAP theorem states that you can only have 2 of 3 properties at once:

  • Consistency: All nodes see the same data.
  • Availability: Every request gets a response.
  • Partition Tolerance: System works even when network connections fail between nodes.

In practice, network partitions are unavoidable in distributed system. Choosing consistency means some nodes will refuse to serve requests rather than return potentially stale data. Choosing availability means different nodes might temporarily have different data.

Eventual consistency (all nodes will converge to the same state given enough time without new updates) is useful when users can tolerate seeing stale data, e.g., their social media feed being 2s old. Strong consistency matters when stale data causes business problems, e.g., overselling products because of a stale inventory.

Different parts of the system can have different consitency requirements, e.g., in an e-commerce system, product descriptions and reviews can be eventually consistent, but inventory counts and order processing need strong consistency.

The PACELC theorem: during a Partition, choose Availability or Consistency; Else choose Latency or Consistency. In normal network conditions, choosing consistency means adding latency because the nodes need to coordinate before responding.

References

  1. Core Concepts for System Design Interviews. www.hellointerview.com . Accessed Jun 6, 2026.