March 5, 2024 4 min read A to Z Series: C Home

CAP Theorem: The Practical Meaning

CAP is useful when it is read as a partition question: during a broken network link, does the system protect consistency or keep accepting work?

I do not use CAP as a slogan. I use it as a production question: when the network splits, should this path keep accepting work or protect one version of truth?

The tradeoff appears during the partition

I use this section to force the failure case into the conversation, not just the clean path.

Before a partition, a system can be both available and consistent enough for its design. The tension appears when messages cannot cross a network boundary. At that point, the system needs a rule that operators and product teams understand.

Checkout example

This example is useful because it shows who owns the work and what breaks when the happy path disappears.

Two regions both accept a balance transfer while the link between regions is down. If both regions can write independently, reconciliation may find that the account spent the same money twice.

Partition handling code

I use the code here to show the decision boundary, not just syntax.

During a partition, make the risky write rule explicit:

Response handle(Request request, boolean partitioned) {
  if (partitioned && request.isRiskyWrite()) {
    return Response.reject("Write paused until replicas agree");
  }
  return request.isRead() ? serveFromLocalReplica(request) : commit(request);
}

The branch makes the CAP tradeoff explicit: reads can continue locally during a partition, but risky writes stop until replicas can agree again.

Sequence diagram: the partition choice

the partition choice CAP is not asking what you prefer on a normal day. It asks what the system does when the link is broken. sd the partition choice Client Client Region A Region A Region B Region B System Rule System Rule Submit a transfer request. Replication message cannotcross the broken link. Another request reaches the isolated region. Either reject risky writes or accept andreconcile later.

CAP is not asking what you prefer on a normal day. It asks what the system does when the link is broken.

The tradeoff to name

Next distributed systems reads

Written by Arunkumar Ganesan.

My recommendation is to stop debating CAP in the abstract and write down what each important user action should do during a partition.

#DistributedSystems #CAPTheorem #Architecture #Reliability