I have explained what is CAP theorem and what all possible combination we can use and when to use which property. ➡️ Join this channel to get access to member only perks: / @conceptandcoding
Partition Tolerance is : System is up and running Even If there is some network partition among nodes. that means, system is able to tolerate partition. Hence partition Tolerant.
Hi, in the 3rd example when the system itself is down(so it is not partition tolerant), we only have consistency but we don't have availability either(so it is not CA)
Great explanation!! The key point that other videos don't tell: Partition Tolerant: Whether the system is able to take requests in case of some network failure in the system. The second thing Availability can be confused with the above definition "If the system is not taking requests how we are achieving availability?' This thing is confusing (individual DB nodes are available but the system itself is not) the A in CAP theorem is talking about whose availability of DB nodes or the system itself. This is confusing. What do you think about this ? how to clear up this concept?
### **Introduction:** - Discusses the concept of CAP Theorem (Consistency, Availability, Partition Tolerance) and its relevance in distributed systems. - Emphasizes the importance of considering CAP constraints early in system design to avoid costly changes later. ### **CAP Theorem:** - **CAP:** Stands for Consistency, Availability, Partition Tolerance. - **Desired Properties of Distributed Systems:** These three properties are desirable in a distributed system. - **CAP Trade-off:** You cannot have all three properties simultaneously. You must choose two out of the three. - **Example:** - Consider a distributed database with nodes in India and the US. - A user's data is replicated across both locations. - A distributed system should ideally be consistent (same data everywhere), available (responding to requests), and tolerant to partitions (network disruptions). ### **Understanding Each Property:** - **Consistency:** Ensures that all nodes have the same, up-to-date data at any given time. - **Availability:** Guarantees that every request is successfully processed by at least one node. - **Partition Tolerance:** Allows the system to continue functioning even if communication between nodes is disrupted. ### **Why CAP Properties Cannot Co-Exist:** - **Case 1: CA (Consistency and Availability) - Not possible with Partition Tolerance** - **Scenario:** A partition occurs, separating nodes A and B. - **Conflict:** Node A writes updated data, but node B cannot access it due to the partition. - **Result:** Inconsistency between nodes. - **Case 2: CP (Consistency and Partition Tolerance) - Not possible with Availability** - **Scenario:** A partition occurs, separating nodes A and B. - **Strategy:** To maintain consistency, only one node (A) is allowed to process writes. - **Result:** Node B becomes unavailable for writes during the partition. - **Case 3: AP (Availability and Partition Tolerance) - Not possible with Consistency** - **Scenario:** A partition occurs, separating nodes A and B. - **Strategy:** To maintain availability, both nodes can process writes. - **Result:** Potential for inconsistent data between nodes. ### **CAP Trade-off in Real-world Systems:** - **Importance of Partition Tolerance:** In today's distributed systems, network disruptions are common. - **Choosing between CP and AP:** - **CP:** Choose this option for systems where consistency is critical, even if it means some temporary downtime. - **AP:** Choose this option for systems where availability is paramount, even if it means some data inconsistency. ### **Key Takeaways:** - **Understanding CAP is crucial for effective distributed system design.** - **Early consideration of CAP constraints can prevent costly changes later.** - **The choice between CP and AP depends on the specific needs of your system.** - **Partition tolerance is a key factor in modern distributed systems.**
Hi , I have quick doubt. When we want to achieve CA so we cant have partition tolerance . so you said that we have to take down the whole system(may be i have misunderstood this) . so in that case we have loss Availability right . so now system is not CA itself . please correct me if i am wrong
Let me try to explain: When we choose "CA" , what we assume that Partition can not even happen in the system. And if partition can not happen, then only thing left is CA. But if Partition happened, means our assumption is false, then we can not choose CA, then we have to choose CP or AP. So CA, can exist in a non distributed world (with a single DB) where never partion can happen.
Hey at the length of 16:35, u explain how we can achieve CA without P by down the whole system whenever P occurs just to maintain the C but in this case System is also not available that means we couldn't not achieve A too and at the end we only got achieved C , right ? in the use case of CA system should available to o right ? can you explain it ? , I don't understand how we achieved A here even though our system is down
For a application to be distributed, it has to support Partition Tolerance, either compromising consistency or availability. A distributed system having CA property is hypothetical and it cannot exist in real world examples. What he means is we can achieve CA without P, by having only one server(then no distributed application). CP - Banking system need consistency so they block all the write operation if any of the node fails, thus system is unavailable, (to provide C and P) AP - Application compromises on Consistency and user can see two different values of a same variable. (to provide A and P) CA - No Partition tolerance at all, means there is only one server, which always have a fresh copy and no need of replication to any nodes, hence not a distributed system. (to provide C and A)
I have quick question regarding above lecture . right now it is not that we are just having distributed databases only , now days we have distributed application as well(like RU-vid or insta) . I mean we have multiple servers or app servers . how does the CAP Theorem can be applied here . because here consistency concept is not applicable . may be partition tolerance we can apply . so basically here we can only think of AP only right ? I am not sure if my question is clear to you or not . In simple terms , how can we apply CAP Theorem on Distributed Application(not database application) ?
See even we have distributed app server but database is not distributed (let's say it's centralised) then CAP can be applied and if we see, out system is only C not fulfilling AP. And if we have distributed database, irrespective whether we have distributed app server or not, then again CAP theorem can be applied and whatever we discussed in the video that is applicable.
Great Explanation bhaiya but, in absence of Partial Tolerance, the combination is Consistency & Availability which means a system is not up and running but it is consistence & avalaible. How it is possible?
Hi sir, I have a doubt, In case of CP, As you told,,, user doesn't know which db node it is requesting,,, even if A gets down user can still request for data,,, and it will get response from B also. So can't we say in this case there is availability of system?
in a CP system, if node A goes down after processing a request and another request comes in, the system relies on the remaining available nodes (like B) to handle the request. The system ensures that B has the necessary data by either replicating the data from A to B before A goes down (as its following Consistency). So we can say with CP, availability get reduced a bit
availability means a distributed system can continue operating and responding to requests, even if some nodes are failing. It doesn't require all nodes to be responsive simultaneously but focuses on the overall system's ability to remain functional during failures.
I have a doubt...i know there would be flaw in it...please try and answer... I think all 3 are possible, If A updates B, C together always, there is no connection between B and C. So it is partition tolerant as if B and C connection breaks no effect, consistent becoz A is updating B and C so data will be same there, And available because both nodes will be available
I have one doubt. CA- here if network parition has happened then the system will shut down. Hence we indirectly compromise the AVAILABLITY too. Correct? Similary, In CP, if network parition happens then the system remains up therefore indirectly we are achieving the AVAILABLITY. Isn’t it??
In CP, we cannot achieve AVAILABLITY because we will have to down the nodes without latest data (otherwise system will reflect different data since the nodes could not be updated due to parttion in system.). If we dont , we cannot achieve Consistency.(same data in all nodes) As for CA, a distributed system having CA property is hypothetical. It cannot exist in real world. We can achieve CA without P, by having only one node (meaning one node, no replicas, so we dont have a distributed system). Hope this helps !
@@amritsatapathy7820thanks, bro. But the system following CP doesn’t go down na. Isn’t it? Shreyansh also said the same. If the system is the following Partitioning then when Network partitioned happens the system breaks into two partitions where devices in partition 1 can communicate and send data to each other and the same with devices in network partition 2 but if some devices from partition. 1 tries to communicate with the device of partition 2 then there will be a delay because the network partitione happened. If the system follows consistency and Partitioning and then still goes down then what is the meaning of following up?
@@Rock28099 Yes bro, the overall system will not go down, but the nodes/devices in partition 2 will be down or specifically, they are shut down so that no requests are served by those nodes and system is kept CONSISTENT. (because if not, they will give diiferent data violating Consistency). So, during this time, if any requests are going to devices of partiton2, we may/may not get a response. Here , the Availablity then gets violated.
It is possible. PACELC is just an extension of CAP by introduction of Latency. But it never says it is introduced because AP is not possible. That's my view but we can discuss more on this.
PACELC is introduced for a use case of Partition itself is not available in a distributed system(DS), then it can choose between Latency and Consistency. 1. Partition is available in DS, it can trade off between Consistency and Availability 2. System is running with out partition, it can trade off between Latency and Consistency So it reverses CAP theorem with PAC and adds else condition for Latency and Consistency, so the name PACELC (Partitioned Availability Consistency Else Latency Consistency)