Skip to content

Cap theorem

The CAP theorem, also known as Brewer's theorem, is a fundamental concept in distributed systems theory. The theorem states that in a distributed system, it is impossible to simultaneously achieve all three of the following guarantees: Consistency, Availability, and Partition tolerance.

Consistency

Consistency refers to the property that all nodes in the distributed system have the same data at any given time. In other words, when a write operation is performed on one node, all subsequent read operations from any node should return the updated data. Ensuring consistency can be challenging in distributed systems, especially in the presence of network delays and failures.

Availability

Availability means that every request made to the system should receive a response, either with the requested data or an error message. In an available system, nodes are expected to be operational and responsive at all times, even in the face of failures or network partitions.

Partition tolerance

Partition tolerance refers to the system's ability to continue functioning even when communication links between nodes are lost or delayed, causing a network partition. Partition tolerance is crucial for maintaining system reliability and avoiding complete failure during network disruptions.

According to the CAP theorem, a distributed system can only prioritize two out of the three properties at any given time. Therefore, when designing and implementing distributed systems, architects must make strategic trade-offs based on the specific requirements and use cases of the application. Some systems may emphasize consistency and partition tolerance at the expense of availability (CA systems), while others prioritize availability and partition tolerance over strong consistency (AP systems). This principle guides system designers to make informed decisions about their system's behavior in the face of various scenarios and trade-offs.

Sources