Skip to content
learn
  1. Learn
  2. High Level System Design
  3. Distributed Systems Theory

System Design HLD-08.03

PACELC and consistency models

PACELC adds the everyday latency versus consistency trade-off to CAP; then the spectrum from linearizable through sequential and causal to eventual consistency.

Advanced 14 min Last reviewed

The big idea

CAP only describes what happens during a partition, which is rare. Most of the time the network is fine, yet replicated systems still face a trade-off on every request: to guarantee a read sees the latest write, replicas must coordinate, which takes round trips, which takes time. PACELCIf there is a Partition, choose Availability or Consistency; Else, in normal operation, choose Latency or Consistency. captures both situations in one line: if Partition, choose Availability or Consistency; Else, choose Latency or Consistency.

"Consistency" is also not one thing. Between "behaves exactly like a single copy" and "copies agree eventually, someday" lies a spectrum of consistency modelsA contract describing which values reads may return given the order of writes, from strict (linearizable) to loose (eventual)., each a different promise about what reads may return. Stronger promises are easier to program against; weaker ones are faster, more available and scale further. Picking the weakest model your feature can tolerate is one of the most valuable design skills.

Think of news. A live phone call with a reporter is strongly consistent but slow and expensive. A daily newspaper is eventually consistent: cheap, fast to read, slightly out of date, and everyone sees events in a sensible order.

How it works

Step 1: PACELC classification

  • PA/EL: during a partition favor availability, otherwise favor latency. Dynamo-style stores such as Cassandra by default: fast and always on, eventually consistent.
  • PC/EC: favor consistency in both cases. Consensus-based systems and distributed SQL such as Spanner or CockroachDB: every write coordinates with a majority, so writes cost at least one round trip to a quorum, across regions if replicas are global.
  • PA/EC and PC/EL exist too, and many systems let you choose per request, for example a quorum read versus a single-replica read.

Step 2: The spectrum

The consistency spectrum from strong to weak A horizontal spectrum. On the strong end, linearizable consistency, with examples etcd and Spanner. Then sequential consistency. Then causal consistency, with examples like collaborative apps and some session guarantees. Then eventual consistency, with examples DNS, Cassandra at consistency level one, and caches. Arrows note that the strong end is easier to reason about and the weak end is faster and more available. Linearizable etcd, Spanner Sequential one global order Causal causes before effects Eventual DNS, caches easiest to reason about fastest, most available Figure 1. Moving right gives up guarantees in exchange for lower latency and higher availability. Moving left makes programs easier to reason about at the cost of coordination.
  • Linearizable: every operation appears to happen at one instant between its start and end; once a write completes, all later reads see it. Needed for locks, leader election, unique usernames.
  • Sequential: all clients see all operations in the same single order, consistent with each client's own order, but that order may lag real time.
  • Causal: operations that are causally related (a reply and the message it answers) are seen in that order by everyone; unrelated concurrent operations may be seen in different orders. It is the strongest model that remains available during partitions, which makes it attractive for collaborative and social apps.
  • Eventual: if writes stop, replicas converge to the same value. No promise about what you read in the meantime.

The session guarantees from Replication lag and read consistency guarantees (read-your-writes, monotonic reads) are useful slices of this spectrum that cost little.

Try it

What is the weakest consistency model each feature can safely use?

Show answers
  • Ensuring a username is taken by only one account: Linearizable. Two concurrent sign-ups must not both succeed, which needs a single agreed order.
  • A comment thread where replies must appear after what they reply to: Causal. Only cause-and-effect order matters; unrelated comments can arrive in any order.
  • The like count shown under a video: Eventual. A slightly old count harms nobody.
  • Electing exactly one leader for a cluster: Linearizable. Every node must agree on the same single leader.
  • Profile pictures served from a CDN: Eventual. Seeing an old avatar for a few minutes is fine.
  • A shared document where edits build on earlier edits: Causal. Each edit must be applied after the edits it depends on.

Going deeper

Why stronger costs latency

A linearizable write must be acknowledged by a majority before it completes, and a linearizable read must either go through the leader with a lease or contact a majority. If replicas are in different regions, that is a cross-region round trip on every operation, tens to hundreds of milliseconds. Spanner reduces read costs with synchronized clocks ( Time and clocks ), but writes still pay the quorum round trip.

Trade-offs

OptionWins whenLoses when
Linearizable Locks, elections, uniqueness, money: correctness above all Latency on every operation and availability during partitions
Causal Social and collaborative features that need sensible ordering while staying available Global uniqueness guarantees; more metadata to track
Eventual Counters, feeds, caches, DNS: maximum speed and availability Any guarantee about what reads return in the meantime

Common mistakes

  • Using linearizable storage for everything and paying cross-region latency on every like.
  • Using eventual consistency for uniqueness constraints and getting duplicate usernames.
  • Assuming "strongly consistent" in vendor docs means linearizable; read the exact guarantee.
  • Forgetting that caches in front of a strong database make reads eventually consistent.

Check yourself

  1. What does the 'ELC' in PACELC describe?

    Show answer

    B. The latency versus consistency trade-off in normal operation Else (no partition), choose Latency or Consistency.

  2. Which model is required to guarantee a username is unique?

    Show answer

    C. Linearizable All clients must agree on a single order of the competing sign-ups.

  3. What does causal consistency guarantee?

    Show answer

    B. Causally related operations are seen in order by everyone Effects never appear before their causes; unrelated operations may be seen in different orders.

  4. Why do linearizable writes cost more latency?

    Show answer

    B. They must be acknowledged by a quorum before completing Coordination with a majority adds at least one round trip, possibly across regions.

Recap

  • PACELC: during a partition choose A or C; otherwise choose latency or consistency.
  • Consistency models range from linearizable through sequential and causal to eventual.
  • Stronger models are easier to reason about; weaker ones are faster and more available.
  • Causal consistency is the strongest model that stays available during partitions.
  • Pick the weakest model each feature can tolerate.

Get new lessons by email

Get new posts on backend and AI internals. No spam, unsubscribe anytime.

Your email is only used to send new posts. Privacy