CAP Theorem: The Core Trade‑off in Distributed Systems
Whenever you design a distributed data store, CAP is the reality check that forces you to make explicit trade‑offs.
CAP Theorem: The Core Trade‑off in Distributed Systems
Whenever you design a distributed data store, CAP is the reality check that forces you to make explicit trade‑offs.

What Is the CAP Theorem?
In database theory, the CAP theorem (also called Brewer’s theorem, after Eric Brewer) states that any distributed data store can provide at most two of the following three guarantees:
- Consistency (C)
- Availability (A)
- Partition Tolerance (P)
Consistency (C)
Every read receives the most recent write or an error. In CAP terms, this means all clients see the same data at the same time, regardless of which node they connect to. For that to happen, a write to one node must be instantly forwarded or replicated to all other nodes before the write is considered successful.
Note: CAP consistency is not the same as ACID consistency in relational transactions. CAP is about replicated data across nodes, not about isolation levels or transactional semantics.
Availability (A)
Every request to a non‑failing node must eventually get a response. There’s no guarantee that the response contains the most recent write; it just has to be “some valid answer.”
This is also different from the “high availability” you hear in ops/SRE. In CAP, availability is about not failing when nodes are alive, even if the data is stale.
Partition Tolerance (P)
The system continues to operate even when the network arbitrarily drops or delays messages between nodes. In real distributed systems, partitions are inevitable, so in practice you almost always assume P and then choose between C and A when it happens.
When a partition occurs, you must decide:
- Cancel or delay operations → reduce availability, but keep consistency.
- Proceed with operations → keep availability, but risk inconsistency.
That’s the essence of CAP: when there’s a network partition, you must choose between consistency and availability.
The Core Trade‑off: What Happens During a Partition?
Imagine a distributed database running on a cluster. Under normal conditions, every node can talk to every other node, so reads and writes can be coordinated.
A partition happens when a network failure (switch failure, cable cut, cloud‑region outage, etc.) splits the cluster into two or more groups that can’t talk to each other.
Now the system faces an unavoidable choice.
CP: Favor Consistency, Sacrifice Some Availability
If the system prioritizes consistency during the partition (CP behavior):
- Every read must return the most recent write or an error.
- If nodes can’t communicate, the system:
- Rejects or delays operations that can’t be safely coordinated.
- Returns errors or timeouts instead of possibly stale data.
From the client’s perspective, this looks like reduced availability: some requests fail or hang until the partition heals. But any successful operation is guaranteed to be consistent with the rest of the reachable system.
AP: Favor Availability, Accept Temporary Inconsistency
If the system prioritizes availability during the partition (AP behavior):
- Every request to a non‑failed node gets a response.
- Reads and writes proceed independently on each side of the partition.
- Replicas may diverge, so a read might not see the latest write from the other side.
Clients see a highly available system — requests succeed even during the outage — but the data can be inconsistent for some time. Once the partition heals, the system reconciles updates (e.g., via version vectors, last‑write‑wins, or custom conflict resolution).
No Partition? You Can Have Both C and A (With P)
The CAP trade‑off only bites during a partition. When the network is healthy and all nodes can communicate, a well‑designed distributed system can provide:
- Consistency: all clients see the same, up‑to‑date data.
- Availability: every request to a non‑failed node gets a response.
- Partition tolerance: the system is architected to survive partitions when they occur.
So in normal operation, you can effectively have C + A + P. CAP forces a choice only when the network actually breaks.
A Simple Visual
Consider a minimal cluster with two nodes:

Now a write arrives at Node A and a read arrives at Node B:
- CP choice: Node B refuses to answer (or blocks) because it can’t confirm it has the latest write → consistent but less available.
- AP choice: Node B answers immediately, possibly with old data → available but inconsistent.
This simple scenario captures the essence of CAP: once communication breaks, you must decide whether to protect correctness © or responsiveness (A).
Short Definitions
- CP: Consistency + Partition tolerance. You give up availability during partitions; reads/writes may be rejected to preserve consistency.
- AP: Availability + Partition tolerance. You keep serving reads/writes during partitions, but accept temporary inconsistencies.
- CA: Consistency + Availability. Theoretical when there are no partitions; not realistic for truly distributed systems across networks. Often used to describe single‑node or tightly coupled setups where partitions are ignored.

Common Misunderstandings & Nuances
“You always have to pick two”
This is the most common mistake. You don’t permanently pick two and forget the third. In normal operation (no partition), you can have C + A + P. The “pick two” part only applies when a partition happens: you must choose between C and A.
“NoSQL = AP, SQL = CP”
That’s also wrong. These are not hard rules tied to technology. They’re more about configurations and trade‑offs:
Default configurations for some systems lean CP (e.g., MongoDB, PostgreSQL in strong setups). Default configurations for others lean AP (e.g., DynamoDB, Redis, Cassandra).
But you can change behavior:
- Tune MongoDB to be more AP‑like with lower consistency levels.
- Configure Cassandra to behave more CP‑like with higher quorum requirements.
So think in terms of CP‑leaning or AP‑leaning under partition, not as permanent labels.
How CAP Relates to Other Models
CAP captures the core trade‑off when a network partition occurs, but it doesn’t model the full range of design choices. Extensions like PACELC build on CAP by adding latency into the picture:
- Without a partition: choose between Latency and Consistency.
- With a partition: choose between Availability and Consistency (the CAP trade‑off).
This makes PACELC more practical for real system design, because it lets you reason about performance and correctness even when the network is healthy.
I’ll cover PACELC in detail in a separate article, so here it’s enough to treat CAP as a starting point, not a complete design guide.
Real‑World Design Implications
Before jumping into examples, it’s useful to see how CAP influences decisions:
- Choice of database for a given architecture
- Consistency models (strong vs eventual)
- Replication strategy and quorum design
Payment System Example
Think about a bank payment system. If you design it as AP:
- A user’s balance might be misleading.
- Someone could withdraw cash at an ATM without the balance being updated in time.
- You could end up with double debits or insufficient funds going unnoticed for some time.
That’s unacceptable for a bank. A payment system must prioritize strong consistency and design its databases in a CP configuration. In practice, this often means:
- Relational SQL databases with strong transactions.
- Quorum‑based replication or consensus protocols if you go distributed.
Social Media Example
For a social media platform:
- High availability is critical.
- It’s acceptable if likes, comments, or follower counts are slightly delayed or inconsistent.
Here, an AP configuration is more appropriate. The system stays available under failures, and inconsistencies are resolved later. This is exactly what you see in big social feeds:
- Counts drift, then converge.
- Users see updates “soon enough,” not necessarily instantly.
Key Takeaways
- CAP applies to distributed data stores.
- Partitions are inevitable in real systems; you must decide between C and A when they occur.
- In normal operation (no partition), you can have C + A + P.
- CAP is a mental model to reason about trade‑offs, not a strict label.
- CAP is not tied to any specific technology; it’s about configuration and design choices.
메타데이터
- post_id
- 3a68ccaca35f
- slug
- cap-theorem-the-core-trade-off-in-distributed-systems-3a68ccaca35f
- url
- https://medium.com/everything-for-developers/cap-theorem-the-core-trade-off-in-distributed-systems-3a68ccaca35f
- canonical_url
- https://medium.com/everything-for-developers/cap-theorem-the-core-trade-off-in-distributed-systems-3a68ccaca35f
- author_url
- https://medium.com/@raphael.lima05
- status
- ok
- fetched_at
- 2026-07-13 06:23:13