skip to content
Mehdi Mehdikhani
CAP Theorem diagram showing Consistency, Availability, and Partition tolerance

CAP theorem states that in distributed system, you can only guarantee two out of three properties: Consistency (all nodes see same data at same time), Availability (system remains operational), and Partition tolerance (system continues to work despite network failures between nodes). This is fundamental constraint that affect every distributed system design decision. Most real-world systems choose partition tolerance because network failures are inevitable, so you’re really choosing between consistency and availability.

CP (Consistency + Partition tolerance) systems prioritize consistency over availability. When network partition happens, they become unavailable rather than serve potentially inconsistent data. Traditional relational databases with ACID transactions fall into this category. AP (Availability + Partition tolerance) systems choose availability over consistency - they keep serving requests even if data might be temporarily inconsistent across nodes. Eventually consistent systems like Amazon DynamoDB or Cassandra are examples of AP systems. They guarantee that if no new updates are made, eventually all nodes will converge to same state.

In practice, its not always black and white choice. Many systems try to be “eventually consistent” where they provide availability during network partitions but work to restore consistency as soon as possible. Some systems also allow you to tune consistency levels per operation - you might choose strong consistency for financial transactions but eventual consistency for user preferences. Understanding CAP theorem helps you make informed trade-offs based on your specific requirements rather than trying to achieve all three properties simultaneously.