In database theory, the CAP theorem, also named Brewer's theorem after computer scientist Eric Brewer, states that any distributed data store can provide only two of the following three guarantees:[1][2][3]
When a network partition failure happens, it must be decided whether to do one of the following:
Thus, if there is a network partition, one has to choose between consistency or availability. Note that consistency as defined in the CAP theorem is quite different from the consistency guaranteed in ACID database transactions.[5]
No distributed system is safe from network failures, thus network partitioning generally has to be tolerated.[6][7] In the presence of a partition, one is then left with two options: consistency or availability. When choosing consistency over availability, the system will return an error or a time out if particular information cannot be guaranteed to be up to date due to network partitioning. When choosing availability over consistency, the system will always process the query and try to return the most recent available version of the information, even if it cannot guarantee it is up to date due to network partitioning.
In the absence of a partition, both availability and consistency can be satisfied.[8]
Database systems designed with traditional ACID guarantees in mind such as RDBMS choose consistency over availability, whereas systems designed around the BASE philosophy, common in the NoSQL movement for example, choose availability over consistency.[9]
Marc Brooker from Amazon Web Services argues CAP Available doesn’t mean ‘highly available to clients’ and availability suffers whether you choose Availability or Consistency. In practice, picking an Availability over Consistency means that it’s going to be more available to some clients in a fairly limited set of circumstances. That may very well be worth it, but it’s in no way a panacea for availability.[10]
According to computer scientist Eric Brewer of the University of California, Berkeley, the theorem first appeared in autumn 1998.[9] It was published as the CAP principle in 1999[11] and presented as a conjecture by Brewer at the 2000 Symposium on Principles of Distributed Computing (PODC).[12] In 2002, Seth Gilbert and Nancy Lynch of MIT published a formal proof of Brewer's conjecture, rendering it a theorem.[1]
In 2012, Brewer clarified some of his positions, including why the often-used "two out of three" concept can be somewhat misleading because system designers only need to sacrifice consistency or availability in the presence of partitions; partition management and recovery techniques exist. Brewer also noted the different definition of consistency used in the CAP theorem relative to the definition used in ACID.[9][13]
A similar theorem stating the trade-off between consistency and availability in distributed systems was published by Birman and Friedman in 1996.[14] Birman and Friedman's result restricted this lower bound to non-commuting operations.
The PACELC theorem, introduced in 2010,[8] builds on CAP by stating that even in the absence of partitioning, there is another trade-off between latency and consistency. PACELC means, if partition (P) happens, the trade-off is between availability (A) and consistency (C); Else (E), the trade-off is between latency (L) and consistency (C).
In February 2012, Eric Brewer provided an updated perspective on his CAP theorem [..] Brewer now describes the "2 out of 3" axiom as somewhat misleading. He notes that designers only need sacrifice consistency or availability in the presence of partitions, and that advances in partition recovery techniques have made it possible for designers to achieve high levels of both consistency and availability.