-uords.png)
The CAP theorem, also known as Brewer's theorem, states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:
- Consistency: Every read request receives the most recent write or update.
- Availability: Every request receives a response about whether it was successful or not.
- Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.
In other words, the CAP theorem states that a distributed system can only provide two of these guarantees at the same time.
For example, a distributed system that prioritizes consistency (such as a database) may sacrifice availability during network partitions, because it cannot allow reads or writes until the partition is resolved and all nodes are consistent again. On the other hand, a distributed system that prioritizes availability (such as a load balancer) may sacrifice consistency, allowing reads and writes to succeed even if some nodes are not up-to-date.
It is important to note that the CAP theorem applies only to distributed systems, and does not necessarily apply to systems that are not distributed (such as a single-node database). In addition, the theorem does not specify how a system should trade off between the three guarantees, or how to design a system that achieves the desired balance of guarantees.
Video: What is CAP Theorem?
📥We'd love to hear your thoughts on this blog post about software engineering salaries and equity! Click here to send your feedback!