CAP Theorem from First Principles

By Pradyumna Chippigiri

December 27, 2025


Let's start by understanding the basic definition of CAP, and then lets delve deep to understand the what, why and how.

CAP Theorm Illustration

CAP Theorem states that in a distributed system, you can have only 2 out of the 3 of the following properties:

Consistency

Every read receives the most recent write or an error. Consistency means that all clients see the same data at the same time, no matter which node they connect to. For this to happen, whenever data is written to one node, it must be instantly forwarded or replicated to all the other nodes in the system before the write is deemed succesfull. Consistency as defined in the CAP theorem is quite different from the consistency guaranteed in ACID database transactions.[

Availability

Every request received by a non-failing node in the system must result in a response, without the guarantee that it contains the most recent version of the data.

Partition Tolerance

The system continues to operate despite arbitrary message loss or failure of part of the system (i.e., network partitions between nodes).

CAP Theorm Illustration


In the real world, network failures are inevitable. Cables are cut, routers fail, and packets are dropped. Therefore, Partition Tolerance (P) is a requirement, not a choice.

When a partition occurs, we are left with a binary choice: Consistency (CP) or Availability (AP).


To be honest, i just picked the above definitions from Wikipedia and pasted them here, as they have stated it beautifully.

So now from the above definitions, the first question that may arise to you is :


Why cant there be a system with both consistency and availability ?

To understand why we can't have all three, let’s look at a practical example

Cluster Partition

Imagine a distributed system with two clusters located in different regions: Asia(the cluster on the left) and the USA(the cluster on the right). Under normal conditions, they sync perfectly. But then, a submarine cable is damaged, and the two regions lose connection. They are now "partitioned."


A user in Asia updates their profile. Since the Asia cluster cannot talk to the USA cluster, we have to make a design choice:



Which one should you choose ?

The choice totaly depends on the usecase of the application.


CP based Applications


These applications need strong consitency.


AP based Applications


Tools or types od DB for each usecase ?

CP based Applications


These kind of applications that demand strong consistency the db which satisfy these are :

AP based Applications


these kind of applications which demand availability and where eventual consistency is okay then we use :

Extended version of CAP

PACELC Therorem

PACELC is another theorem, an extension of the CAP theorem. Wikipedia states that in the case of network partitioning (P) in a distributed computer system, one has to choose between availability (A) and consistency (C) (as per the CAP theorem), but else (E), even when the system is running normally in the absence of partitions, one has to choose between latency (L) and loss of consistency (C).



Hope you got a fair understanding of the CAP theorem, if you liked it please do Subscribe to my weekly newsletter! and consider sharing it with your friends on social media if you found this helpful.