# CAP theorem (Brewer’s theorem)

In computer science, CAP theorem, also known as Brewer's theorem, states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees:

- Consistency: Every read receives the most recent write or an error
- Availability: Every request receives a (non-error) response – without the guarantee that it contains the most recent write
- Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes

The theorem is named after computer scientist Eric Brewer, who first formulated it in 2000. It is based on work by computer scientist Gilbert and Lynch, who proved in 1996 that it is impossible for a distributed data store to provide all three of these guarantees simultaneously.

The CAP theorem has important implications for the design of distributed systems. In particular, it suggests that one must choose between consistency and availability when designing a distributed system; it is impossible to have both at the same time.

One common way to deal with this trade-off is to use a technique called "eventual consistency", which relaxes the consistency guarantee in exchange for availability. Eventual consistency is often a good choice for systems that are designed to be used by humans, since humans are good at dealing with inconsistency.

Another way to deal with the CAP theorem is to use a technique called "strong consistency", which relaxes the availability guarantee in exchange for consistency.

##### What is CAP theorem in HBase?

The CAP theorem is a theorem in computer science that states that it is impossible for a distributed system to simultaneously provide more than two of the following three guarantees:

- Consistency
- Availability
- Partition tolerance

In other words, the CAP theorem states that it is impossible to have a distributed system that is both consistent and available in the presence of network partitions.

The CAP theorem is often used to explain the trade-offs that exist in distributed systems. For example, a distributed system that is consistent but unavailable in the presence of network partitions is said to be operating in the CA mode. A distributed system that is available but not consistent in the presence of network partitions is said to be operating in the AP mode.

HBase is a distributed system that is designed to provide high availability and scalability. However, HBase does not provide strong consistency guarantees. In other words, HBase is an AP system.

The lack of strong consistency guarantees in HBase means that data may be stale or inconsistent in the event of a network partition. However, HBase will always guarantee that the data is available, even in the event of a network partition.

##### What does CAP in the CAP theorem stand for?

The CAP theorem states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:

- Consistency: Every read receives the most recent write or an error
- Availability: Every request receives a (non-error) response – without guarantee that it contains the most recent write
- Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes

The theorem is named for the three key concepts it captures: Consistency, Availability, and Partition tolerance.

### Is CAP theorem still valid?

CAP theorem states that it is impossible for a distributed computer system to simultaneously provide more than two of the following three guarantees:

- Consistency: Every read receives the most recent write or an error
- Availability: Every request receives a (non-error) response – without guarantee that it contains the most recent write
- Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes

It is still valid today.