We have all probably heard about the CAP theorem at some point in our careers.
The statement is simple: you can only achieve two out of the following three properties at any given time:
Consistency: All nodes have the same data view.
Availability: Every request receives a non-error response.
Partition tolerance: The system can function even when network partitions occur.
Based on this definition, a database is available even if a query returns a response after 15 days.
But let’s be real: that latency is unacceptable for any real-world application.
This is when The PACELC Theorem came to the rescue.
And is looking to answer the question: What happens during normal operation (when there is no partition)?
Systems have to choose between Latency and Consistency.
A real-world Example:
Let’s say we have a real-time multiplayer online game with a global leaderboard.
The game has servers distributed worldwide and shows player scores and rankings.
With Partition, you have:
Availability and Partition Tolerance (AP)
The American and European clusters independently update their local leaderboards.
Players in both regions can still see and update their scores, but the leaderboards will not align until the partition is resolved.
Consistency and Partition Tolerance (CP)
The game blocks leaderboard updates in American and European clusters until the network issue is resolved.
This provides a consistent global leaderboard but sacrifices availability during the partition.
Now, let's assume there's no partition (P):
Latency over Consistency (LC)
The system updates the closest server immediately when a player finishes a game.
This quick update offers low latency but takes time to reach other servers.
During this lag, players connecting to different servers may see outdated leaderboard information.
Consistency over Latency (CL)
When a player finishes a game, the system updates all servers before confirming the score.
This method ensures a globally consistent leaderboard but increases response time.
CAP is a good starting point, but PACELC provides a more complete framework.
This is helpful. Thanks👍
Awesome post brother! Keep them coming!