CAP theorem  is also called as Brewer’s theorem.
C – Consistency
A- Availability
P- Partition Tolerance

Presented by Eric Brewer in 2000, essentially states for a distributed system, Consistency, Availability and Partition-tolerance cannot be “achieved” all at the same time.

Consistency:-

All nodes see the same data at the same time.
roughly meaning that all clients of a data store get responses to requests that ‘make sense’. For example, if Client A writes 1 then 2 to location X, Client B cannot read 2 followed by 1.

 Availability:-

A guarantee that every request receives a response about whether it succeeded or failed.
all operations on a data store eventually return successfully. We say that a data store is ‘available’ for, e.g. write operations. 

 Partition Tolerance:-

The system continues to operate despite arbitrary partitioning due to network failures.

truth-of-cap-theorem-diagram

 

 

 

 

 

 

how we can assure consistency?
Always write to and read from majority of nodes.
At least one node should know most recent value.

pick any two.
At most 2 of 3 properties may be satisfied.
A distributed file system can satisfy any of two CAP  guarantees at the same time  but not all the three.

Consistency + Availability .
Consistency + Partition Tolerance .
Availability + Partition Tolerance.

Databases and CAP Theorem
The following diagram depicts where each database falls and which two of the three features they select.