CAP theorem⚓︎
CAP⚓︎
Definition
The CAP
theorem is a principle that describes the limitations of distributed data storage systems. It states that in a distributed system, you can only guarantee two out of the following three properties simultaneously:
-
Consistency (C): Every read receives the latest write or an error, ensuring that all nodes in the system return the same data.
-
Availability (A): Every request (read or write) receives a response, even if some nodes in the system are down.
-
Partition Tolerance (P): The system continues to operate even if there is a communication breakdown between some parts of the system (network partitions).
Applications of CAP⚓︎
Applications
According to the theorem, when a network partition occurs, a system can either:
- Maintain Consistency and sacrifice Availability (returning an error instead of outdated data).
- Maintain Availability and sacrifice Consistency (returning potentially outdated data from other nodes).
In essence, the CAP theorem helps guide the design choices for distributed systems based on the trade-offs between these properties. Thus for the applications, we can classify them into three categories:
- CA: Traditional RDBMS - MySQL, PostgreSQL, SQL Server
- CP: Redis, HBase, MongoDB
- AP: DynamoDB, Cassandra, Couchbase