CAP Theorem in NoSQL Databases
1. Introduction
The CAP theorem, proposed by Eric Brewer, applies to distributed database systems. It states
that a distributed system cannot simultaneously guarantee all three properties:
C – Consistency
A – Availability
P – Partition Tolerance
In other words, a distributed database system can provide at most two of these three properties
at the same time. This is fundamental in the design of NoSQL databases, which are often
distributed across multiple nodes.
2. CAP Properties
Property Description Example
In a banking system, after
Consistency All nodes see the same data at the same transferring money, all users
(C) time after an update. immediately see the updated
balance.
Availability Every request receives a response, even if Users can still query a website or
(A) some nodes fail. database even if one server is down.
The system continues to operate correctly During a network failure between
Partition
even if communication between nodes is two servers, both continue to operate
Tolerance (P)
lost (network partition). independently.
3. CAP Trade-offs
A distributed system can choose only two of the three properties:
1. CA (Consistency + Availability) – Not tolerant to network partitions.
2. CP (Consistency + Partition Tolerance) – May sacrifice availability during network
failure.
3. AP (Availability + Partition Tolerance) – May temporarily compromise consistency;
data eventually becomes consistent.
4. Examples in NoSQL Databases
CAP
Database Behavior
Choice
Ensures consistency and partition tolerance; availability may be reduced
MongoDB CP
during network failure.
Cassandra AP Ensures availability and partition tolerance; uses eventual consistency.
Maintains consistency and partition tolerance; availability may be
HBase CP
affected during network issues.
CouchDB AP High availability and partition tolerance; eventual consistency is applied.
5. Significance in NoSQL Database Design
Helps database designers choose the right system for specific application needs.
Explains the trade-offs between consistency, availability, and fault tolerance.
Guides the design of scalable and reliable distributed systems.
Enables implementation of eventual consistency in systems requiring high availability.
Provides a framework to balance performance, reliability, and data accuracy.
6. Diagram: CAP Theorem Triangle
Consistency
/\
/ \
/ \
/ \
/ \
Availability ---- Partition Tolerance
A distributed system can choose any two properties but cannot guarantee all three
simultaneously.
7. Conclusion
The CAP theorem is a fundamental principle for NoSQL and distributed database design.
It helps developers understand limitations and trade-offs when building systems that need to
handle large-scale, distributed, and highly available data.
Financial apps → prioritize CP (Consistency + Partition Tolerance)
Social media apps → prioritize AP (Availability + Partition Tolerance)