Understanding the CAP Theorem
2 Nov 2026, 8:39 pm
As developers, we often assume that distributed systems can provide everything at once: perfectly consistent data, high availability, and resilience to network failures. Unfortunately, distributed systems don't work like that.
This is where the CAP Theorem comes in, one of the most fundamental concepts in distributed computing. What Is the CAP Theorem?
Proposed by computer scientist Eric Brewer, the CAP Theorem states that a distributed system can guarantee only two of the following three properties simultaneously:
Consistency (C) Availability (A) Partition Tolerance (P)
When a network partition occurs, you must choose between consistency and availability. Consistency
In the CAP Theorem, consistency refers to linearizability[2] This means that every read receives the most recent successful write, or an error. The system behaves as if all operations happened in a single, globally consistent order.
For example, if you update a user's account balance, any subsequent read should return the updated value, regardless of which node handles the request.
From the user's perspective:
Read-after-write returns the latest value No stale data is returned All operations follow a consistent order Availability
Availability means every request receives a response, even if some servers are experiencing issues.
The response might not contain the most recent data, but the system remains operational.
Examples:
Social media feeds: If User X updates their profile info, it's just fine if User Y sees the old info for a few minutes. Product recommendations Content Platforms Analytics dashboards Review Sites (Yelp etc.)
These systems often prioritize availability over strict consistency. We can basically ask ourselves "Would it be catastrophic if users briefly saw inconsistent data?" If the answer is yes, choose consistency. If not, choose availability[1] Partition Tolerance - Not Optional
A partition happens when nodes cannot communicate because of network failures."Partition Tolerance” is the the ability of a distributed system to continue operating even when a partition occurs.
In modern cloud environments, partitions are not hypothetical events.
They happen because of:
Network outages Region failures Router issues Infrastructure maintenance
Since partitions are unavoidable, most distributed systems must support partition tolerance. Because you cannot prevent hardware failures or router crashes.The systems should not be affected by network partitions. Therefore, any distributed system must be partition-tolerant. A Real-World Example: The ATM
Imagine you have $1,000 in your bank account and two ATMs connected to different bank servers.
You withdraw $200 from the first ATM, but a network failure prevents the second server from receiving the update 🫣 The second ATM still shows your balance as $1,000.
Now, you try to withdraw another $900 from the second ATM. • Consistency (CP): The ATM rejects the transaction because it cannot verify you…
https://dev.to/glnurltn/about-cap-theorem-472k