CAP Theorem

Saurav Kumar
4 min readNov 17, 2023

The CAP theorem, or Brewer’s theorem, states that in a distributed system, it is impossible to simultaneously achieve Consistency, Availability, and Partition tolerance, proposed by computer scientist Eric Brewer, describes the trade-offs in distributed systems. You can prioritize two of these aspects, but the third will be compromised. Let’s break down the three components:

  1. Consistency (C): All nodes in a distributed system see the same data at the same time. In a consistent system, if a write is successful, all subsequent reads will reflect that write.
  2. Availability (A): Every request to the system receives a response, without guarantee that it contains the most recent version of the information. An available system continues to function and respond to requests even in the face of network failures.
  3. Partition Tolerance (P): The system continues to operate despite network partitions (communication breakdowns) that might occur. Partition tolerance is crucial in distributed systems where nodes are geographically separated, and network issues can occur.

Now, let’s explore the trade-offs with an example:

Consider a distributed database system with nodes in different locations. During a network partition (P), two sets of nodes can’t communicate with each other. Now, you have to choose between consistency and availability:

--

--

Saurav Kumar
Saurav Kumar

Written by Saurav Kumar

Experienced Software Engineer adept in Java, Spring Boot, Microservices, Kafka & Azure.

No responses yet