CAP theorem
Written by haloboy777 on 2024-10-25
Notes on CAP theorem
So CAP theorem states that Distributed systems can strive for three characteristics
- Consistency
- Availability
- Partition Tolerance
However the CAP theorem states that there is a trade off between these three attributes, we can only choose two out of these three
Availability
We still be able to serve requests when there is some kind of failure. When some of our nodes in our distributed system become unavailable.
This is done by replicating data. For each piece of data, we have multiple copies spread across multiple DBs.
Consistency
For our read request we will always get the latest write.
Partition Tolerance
In case of a network failure between nodes, the system should work and try to get back to consistent state when failure disappears.
Examples
CP databases
- Apache HBase
- MongoDB
AP databases
- ScyllaDB
- Casandra
- DynamoDB
CA databases
- Vertica
- MySQL
- Postgres
This doesn't mean databases don't have all three attributes. But the databases favours certain attributes in favour of other in case of a failure.