Do you know about the CAP theorem?
It relates to our real-life a lot but is applicable for distributed systems.
1. CAP in CAP theorem stands for Consistency, Availability, Partition tolerance. The theorem states that in any distributed data store, one cannot have all three. You have to sacrifice at least one. This theorem is applicable to databases too. Much like our real life. We cannot have everything, we need to lose something to gain the other.
2. One thing to note here is that consistency and availability in the CAP theorem are different from the consistency and availability in the “ACID” properties of a database. CAP applies to distributed data store not just a single node unlike “ACID”.
3. Consistency means that after you do a successful write, future reads will always take that write into account. Availability means that you can always read and write to the system.
4. Partition tolerance means that the cluster must continue to work despite any number of communication breakdowns between nodes in the system i.e even if the connection between some nodes fails or the node itself fails, the system must not go down.
5. One catch with the CAP theorem is that there are no “CA” types of system, because a system may not support C or A, it must support partition tolerance. Therefore, systems are either CP or AP.
6. AWS DynamoDB is a highly available datastore which makes it AP type of system. The systems which are of AP type, support eventual consistency i.e you might not always get the latest data, but the chances of failure are very low.
7. Mongo DB on the other hand which is again a No-SQL data store like Dynamodb is a CP type of system. It s a single-master system each replica set can have only one primary node that receives all the write operations. If this fails, another node is elected primary. During this type, the client cannot perform writes.
8. One claim that beats CAP theorem: https://lnkd.in/eKCy8qTT. That comes with certain constraints.