CAP theorem

Distributed system is a system whose components are located in different computer systems and all these nodes are able to communicate by passing messages to each other.In computer science, the CAP theorem, also named Brewer’s theorem after computer scientist Eric Brewer. This theorem state that it is impossible for any distributed system to achieve more than two out of three properties at the same time.

C – Consistency: All nodes in distributed system should have same data at the same time. We can achieve consistency by updating every node with latest write action so user can read up-to date data.
A – Availability: All nodes should be available for reading of data and system should be available.
P – Partition tolerance: There is network failure and because of that, two nodes are unable to communicate with each other.

According to this theorem, we can achieve only two properties out of these three.

Consistency & Availability: If there is no network failure, then definitely as all nodes are available for reading and all nodes will always be updated with latest data. Hence, user will always get the consistent data through out all available nodes.

ca

Availability & Partition tolerance: If there is a network failure between two nodes of distributed system, nodes won’t have consistent data as two nodes cannot communicate with each other and one of the node does not have up-to-date data. Example: When user updates his profile, write action occurs on one of the node. However, due to network failure, other nodes of system cannot receive recent data and whenever that node will serve the request, user won’t get consistent data.

ap

Consistency & Partition tolerance: To achieve consistency in case of network failure, Node which has out of date data should stop serving requests but then there won’t be 100% availability of all nodes.

cp

Leave a Reply

Your email address will not be published. Required fields are marked *