CAP Theorem (Consistency - Availability - Partition Tolerance)
- states that a distributed system cannot simultaneously guarantee all three properties:
- Consistency
- Availability
- Partition Tolerance
- this means that when designing distributed systems, developers must make trade-offs, choosing which two properties are most important for their application
CAP - Introduction
CAP Properties
Consistency | - all nodes in the system see the same data at the same time
- this means all reads receive the most recent write or an error
|
---|
Availability | - every request receives a (non-error) response, even if the data is not the most recent
- this ensures that the system is always operational and can respond to requests, even if some nodes are unavailable
|
---|
Partition Tolerance | - the system continues to operate despite network partitions or communication failures between nodes
- this means the system can handle situations where nodes are disconnected from each other due to network issues
|
---|
CAP Trade-Offs
CP (Consistency and Partition Tolerance) | - Sacrifices availability
- The system prioritizes keeping data consistent even during network partitions, but may become unavailable or have limited availability if nodes are disconnected
|
---|
AP (Availability and Partition Tolerance) | - Sacrifices consistency
- The system prioritizes being available and continuing to operate during network partitions, but may not guarantee data consistency across all nodes
|
---|
CA (Consistency and Availability) | - Cannot guarantee partition tolerance
- In a distributed setting, this combination is theoretically impossible because network partitions are inevitable
|
---|
In summary, when designing a distributed system, you must choose which two of these properties are most important for your application and its specific needs, understanding that you will need to make a trade-off and sacrifice the third property.