PACELC Theorem

The PACELC theorem is as follows:

If the network is partitioned, we choose between availability and consistency else, we choose between latency and consistency.

This definition was introduced to encompass latency's role in distributed systems that operate without network partitions.

Before PACELC there was CAP

CAP theorem
CAP theorem

The CAP theorem proposed that due to the nature of distributed systems, they could only provide two of the following three guarantees:

  1. Consistency

  2. Availability

  3. Partition tolerance

This theorem allows programmers to weigh the trade-offs according to their product's needs. Let's understand each of them below:

Consistency

By consistency, we mean the system can read the most updated version of the data or else return an error.

The replica here is a node that asynchronouslyNot at the same time syncs with the original node, where the original source of the data is present. The replica does have a copy of the original data but it might be stale.

User requests a read and the replica pings the original copy to get the latest version
1 of 3

Availability

By availability, we indicate the system should respond with non-error replies to all requests.

User requests a read and the replica pings the original copy to get the latest version
1 of 3

Partition tolerance

By partition tolerance, we mean the system to be unhindered by packet drops or delays due to the network. So this would mean we have the perfect network and routers that never failed or had multiple contingency paths to all nodes on the distributed system.

Note: When trading off partition tolerance for consistency and availability (CA) we cannot completely sacrifice partition tolerance as we will always have delays and packet drops in a distributed system.

As we can see below, we can wait a pretty long while but provide consistency and availability. This means that the user may face delays indefinitely.

User requests a read and the replica pings the original copy to get the latest version
1 of 3

Concluding the CAP and PACELC theorems

So, in essence, the CAP theorem suggests developers have to choose between either consistency or availability since we can always face network partitions.

PACELC theorem
PACELC theorem

However, the CAP theorem forces us to assume that the system has network partitions, which is not necessarily the case at all times. So the PACELC is used as a more flexible theorem to understand the trade-offs in distributed systems. Both DynamoDB and Cassandra are PACIf partition occurs, give up consistency for availability. / ELCElse give up consistency for lower latency. systems by default.

Copyright ©2024 Educative, Inc. All rights reserved