← Back to System Design, page 1

system-design-0004 · Medium mid

What is the PACELC theorem and how does it help you compare databases beyond CAP?

PACELC says: if there is a Partition, choose Availability or Consistency; Else, in normal operation, choose Latency or Consistency. It captures the everyday cost of strong consistency, which is the extra round trips needed to coordinate replicas, something CAP ignores.

Full answer

The statement

Partition then A or C; Else L or C.

CAP only describes what happens during a partition. But partitions are rare, while the latency cost of consistency is paid on every request. To give a read the latest value, a system usually has to contact a leader or a quorum of replicas, sometimes across regions. Answering from the nearest replica is faster but may be stale.

How it works in practice

Consider data replicated in three regions with a 70 ms round trip between them (an assumption for this example).

  • EC (consistency in normal times): a write must be acknowledged by a majority before success. Each write pays at least one cross-region round trip, about 70 ms extra.
  • EL (latency in normal times): the write is acknowledged locally and copied asynchronously. The client sees a few milliseconds, but a read in another region may miss the write for a short time.

Classifying systems

  • PA/EL: Cassandra and DynamoDB in their default settings. Stay available under partition and favour low latency normally. Both can be tuned towards consistency per request.
  • PC/EC: systems built on consensus, such as etcd, ZooKeeper, and Spanner-style databases. They pay coordination cost always.
  • PC/EL or PA/EC exist too. A single-leader database with asynchronous replicas and reads from followers behaves EL for those reads.

These labels describe default configuration. Many databases let you change them per query, for example quorum reads in Cassandra or reading from the leader in a replicated SQL setup.

When it helps

PACELC is the better lens when choosing a store for a latency-sensitive global product. For a user profile read on every page, EL with read-your-writes guarantees for the owner is often enough. For an account balance or inventory decrement, pay the EC cost on that one path.

By level

Fresher: State the theorem and explain that keeping copies in sync costs time even when nothing is broken. Naming the two branches, partition and else, is enough at this level.

Mid: Use round-trip times to estimate the write latency of quorum versus asynchronous replication, and classify common databases with their tunable options. A good answer shows the cost in milliseconds from a stated round-trip time.

Senior: Design per-operation consistency for a global product, discuss leader placement, follower reads, bounded staleness and clock-based approaches, and quantify the user-visible latency budget for each choice. Expect a per-operation plan, not one label for the whole product.

Key points

  • PACELC adds the normal-time trade-off between latency and consistency
  • Strong consistency costs coordination round trips on every request
  • PA/EL and PC/EC are the common combinations
  • Labels describe defaults; many stores are tunable per request
  • Apply the expensive mode only to the operations that need it

Common mistakes

  • Thinking consistency only costs something during failures
  • Assigning a fixed label to a tunable database without saying "by default"
  • Forgetting cross-region round-trip time when estimating write latency
  • Mixing up the E (else) branch with eventual consistency

Follow-ups

  • How would you give a user read-your-writes in an EL system?
  • What does Spanner do to reduce the EC latency cost?
  • Where would you place the leader in a multi-region single-leader setup?

Tips

  • Spell out the acronym slowly, then give the latency example
  • Use a stated round-trip assumption to show the cost in milliseconds
  • Classify one database you know and add "by default"

Evaluation rubric

  • States the theorem correctly
  • Explains why the else branch matters more day to day
  • Gives a numeric or concrete latency example
  • Classifies at least one system with nuance