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

When I talk about "The tradeoff appears during the partition", I am really asking what CAP Theorem does when a message is late, duplicated, or missing.

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

I use "Checkout example" to keep CAP Theorem grounded in a real system, because abstract patterns are too easy to agree with and too hard to operate.

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

When I show "Partition handling code", I want the code in CAP Theorem to reveal the production decision, not just the 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