Exploring Key Distributed System Algorithms and Concepts Series: 5— CAP and PACELC Theorems.
CAP Theorem: Consistency, Availability, Partition Tolerance

for detail read my article on CAP
CAP theorem, formulated by Eric Brewer in 2000, is a cornerstone concept in distributed systems. It addresses the trade-offs between three crucial attributes: Consistency, Availability, and Partition Tolerance.
- Consistency: In a distributed system, consistency implies that all nodes or replicas of a data store will have the same data at any given time. In other words, every read operation returns the most recent write. Achieving strong consistency ensures that there is no ambiguity when accessing data.
- Availability: Availability means that every request, whether for reading or writing data, will receive a response (not necessarily the most recent data). High availability ensures that the system remains responsive even if some nodes fail.
- Partition Tolerance: Partition tolerance is the system’s ability to function correctly even when network partitions occur, leading to communication failures between nodes. Network partitions can be caused by various factors such as network congestion, hardware failures, or software errors.
How CAP Works
The CAP theorem states that in a distributed system, you can achieve at most two out of the three attributes: Consistency, Availability, and Partition Tolerance. This means that when a network partition occurs (P), you have to make a trade-off between Consistency © and Availability (A).
- CA Systems: These systems prioritize both Consistency and Availability over Partition Tolerance. In cases of network partition, they may become unavailable until the partition is resolved, ensuring that data remains consistent.
- CP Systems: These systems prioritize Consistency and Partition Tolerance over Availability. They may become temporarily unavailable during network partitions to maintain strong consistency.
- AP Systems: These systems prioritize Availability and Partition Tolerance over strict Consistency. They can continue to operate during network partitions, even if it means sacrificing some level of data consistency.
Real-Life Examples of CAP:
- Amazon DynamoDB: Amazon DynamoDB, a managed NoSQL database service, is an example of an AP system. It prioritizes high availability and partition tolerance, making it suitable for scenarios where real-time access to data is crucial, even if it means allowing eventual consistency.
- Google Spanner: Google Spanner is a globally distributed database that leans towards CP. It ensures strong consistency by synchronizing time across data centers, making it suitable for applications that require strong guarantees on data consistency.
- MongoDB with Replica Sets: MongoDB can be configured to be CA within a single data center, but it often operates in a CP mode when used across multiple data centers. This configuration allows users to choose between strong consistency or high availability based on their needs.
PACELC Theorem: Latency vs. Consistency

for detail read my article on PACEL
PACELC theorem, proposed by Daniel Abadi in 2010, refines the CAP theorem’s Partition Tolerance concept by introducing latency considerations.
PACELC Components:
- P (Partition Tolerance): Like in the CAP theorem, this represents the ability of the system to continue functioning during network partitions.
- A (Availability): Availability, in the context of PACELC, focuses on the system’s ability to provide responses within a certain time frame.
- C (Consistency): Consistency, as per PACELC, also refers to the system’s ability to maintain a specific level of data consistency.
- E (Else): E represents the system’s behavior when it’s not possible to guarantee both Availability and Consistency due to a network partition.
- L (Latency): Latency is a new consideration in PACELC and denotes the acceptable time frame for operations.
How PACELC Works
PACELC extends the CAP theorem by emphasizing the importance of latency in distributed systems. It recognizes that in scenarios where network partitions occur, a trade-off between Consistency and Low Latency (A) may be necessary. In other words, during network partitions, you may need to accept slightly stale or out-of-date data to provide low-latency responses to clients.
Real-Life Examples of PACELC:
- Twitter Timeline: Twitter’s timeline is an example of a system that adheres to the PACELC theorem. During network partitions or high traffic, you may occasionally see slightly outdated tweets in your timeline to ensure that Twitter remains highly available and responsive.
- Content Delivery Networks (CDNs): CDNs like Cloudflare aim for high Availability and Low Latency. In cases of network disruptions, they may serve cached content, which might not be the most up-to-date, to maintain low-latency access for users.
- E-commerce Inventory Systems: In e-commerce, inventory systems often prioritize Availability and Low Latency over strict Consistency. During peak shopping periods, you might see products listed as available even if they have just been sold, ensuring a smooth shopping experience.
Conclusion
Understanding the CAP and PACELC theorems is essential for designing and operating distributed systems effectively. These theorems provide valuable insights into the trade-offs and guarantees associated with data consistency, availability, partition tolerance, and latency. Real-world examples further illustrate how these principles are applied in various applications, allowing engineers and architects to make informed decisions when designing distributed systems that meet their specific requirements.
If you found this article helpful, please don’t forget to hit the Follow 👉 and Clap 👏 buttons to help me write more articles like this.
Thank You 🖤
Thank you for Reading !! 🙌🏻😁📃, see you in the next blog.🤘
About the Author:
Name: Gurpreet Singh Job Role: Senior SRE Mail : gurpreet.singh_89[@]outlook.com 🚀GitHub : https://github.com/supersaiyane 🚀Linked-in : https://www.linkedin.com/in/gurpreetsinghpal/ 🚀Medium: https://medium.com/@gurpreet.singh_89 🚀Subscribe me @ : https://medium.com/@gurpreet.singh_89/subscribe 🚀Tech-Blog: https://www.linkedin.com/company/techbulletin
The end ✌🏻





