System Design Academy

Saving…

Lesson 6 of 10 in Module 50 of 54 lessons complete

CAP Theorem & PACELC

Module 5, lesson 6Concept12 min

Definition

Network partition

In plain English
A network partition is when machines in a system are running but can't reach each other.
Think of it like
It is like two halves of a team on a phone line that keeps cutting out.

CAP theorem

In plain English
The CAP theorem says that during a network partition, a replicated system must choose between consistency (everyone sees the same latest data) and availability (every request gets an answer).
Think of it like
It is like two shop branches that lose their phone link and must either stop selling the last item or risk both selling it.

PACELC

In plain English
PACELC extends CAP: if there's a Partition choose Availability or Consistency, Else choose between Latency and Consistency.
Think of it like
It is like deciding not only what to do in a storm but also whether to drive fast or carefully on a normal day.

Why it exists

Two dispatch servers lose their network link. Both still run, but neither knows whether the other assigned the last free ambulance.

In CAP, consistent means every reader sees the latest change, as if there were only one copy.

Available means every working server still gives a real answer. Replying with an error does not count.

How it works

Two clients reach separate live nodes whose link cannot carry messages.

Both sides run but cannot coordinate.

Two clients reach separate live nodes whose link cannot carry messages.

ChoiceDuring a partitionUser seesUseful when
CP: consistency over availabilityRefuse operations that cannot be safely coordinatedSome errors or waitingConflicting assignments are dangerous
AP: availability over consistencyAnswer without waiting for unreachable copiesPossibly stale or conflicting valuesOld schedule data remains useful
  • PACELC also considers normal operation: coordinating distant copies can add latency.
  • Synchronous replication waits for other copies, but waiting alone does not guarantee every read is fresh.
  • Asynchronous replication can acknowledge sooner, while reads on lagging copies may return old data.
  1. Choose per operation

    Ask what a wrong answer would cost compared with an unavailable answer.

  2. Specify the response

    Document which side may answer and which operations must wait or fail.

  3. Plan recovery

    If both sides accept changes, define how their conflicting updates are resolved.

Examples

Refuse an uncertain assignment

The dispatch system cannot confirm whether an ambulance remains free across a partition.

An assignment request succeeds only when exclusive ownership can be confirmed; otherwise it is refused and a dispatcher is alerted.

Consistency protects exclusive assignment.

An assignment request succeeds only when exclusive ownership can be confirmed; otherwise it is refused and a dispatcher is alerted.

This operation chooses CP. It needs an atomic assignment check as well as fresh data, so two callers cannot both reserve the same ambulance.

The insight

Choose consistency when conflicting actions are dangerous.

Trade-offs

Pros

  • CP avoids conflicting operation histories.
  • AP preserves responses from reachable nodes.

Cons

  • CP can reject work during partitions.
  • AP can require conflict resolution.

Use when

  • Assignments need one agreed result.
  • Read-only schedules can tolerate old data.

Avoid when

  • One system-wide label hides different operation needs.
  • Treating an error message as “still available”.

Quick check

During a partition, a system refuses requests it can't confirm are up to date. Which side has it chosen?
What does the "ELC" in PACELC add?

Takeaways

  • Partitions can force you to sacrifice consistent responses or successful responses.
  • Choose guarantees per operation using the cost of wrong and missing answers.
  • PACELC adds the latency and consistency choice during normal operation.

Try the quick check above whenever you feel ready.

Previous: Consistent Hashing