Skip to content
CENTRAL UNIVERSITY
Lecture

CAP, PACELC and Consistency Models

A story about real trade-offs in distributed systems

/ CAP, PACELC and Consistency Models · Central University

Slide contents

  1. 1. CAP, PACELC and Consistency Models

    A story about real trade-offs in distributed systems

  2. 2. Lecture Map

    From theorems to engineering decisions

    First — CAP: C/A/P and correct reading.

    Then — PACELC profile for product needs.

    Finale — Jepsen, models and Cassandra.

  3. 3. CAP Theorem in One Phrase

    During a partition you cannot guarantee both C and A simultaneously

    For shared-data systems

    C: linearizability

    A: live node responds

    P: message loss

  4. 4. C, A, and P: What's Inside

    Formal definitions over marketing

    Consistency

    One global order

    Read-after-write sees the latest value.

    CAP means linearizability

    Availability + Partition

    Availability: response without deadline

    Partition: message loss

    Together they conflict with C

  5. 5. Consistency in CAP = Linearizability

    Why this is stricter than 'just identical data'

    Total order matches real time

    Operation appears instant

    System behaves as one node

    Replica desync violates guarantee

  6. 6. Availability in the Theorem

    Weak on timing, but strong on obligation

    Live node must respond

    No deadline, but termination

    Waiting for sync loses A

    CP often returns error/timeout

  7. 7. How CAP Emerged

    From conjecture to proof

    1998: Brewer formulates CAP.

    1999: harvest/yield, fault tolerance.

    2000: CAP reaches PODC.

    2002: Gilbert/Lynch prove it.

  8. 8. The 'Pick 2 of 3' Myth

    Useful, but too crude

    CAP trade-off arises during partition.

    Peacetime can deliver C and A.

    Strategy is often per-operation.

    Need degradation rules, not labels.

  9. 9. Partitions: Rare, Not Exotic

    You can't ignore them

    Packet loss and zone breaks happen

    Question: system behavior during partition.

    Timeouts create false partitions

    Need enter/exit runbooks

  10. 10. Decisions Are Made Per Operation

    One product can combine CP and AP behavior

    Money often requires CP

    Feeds often allow AP

    APIs can behave differently

    Stale reads must be explicit

  11. 11. C/A/P Are Spectrums

    Architecture is about gradations

    Availability = uptime/error budget.

    Consistency: eventual → linearizable.

    Partition can be partial and asymmetric.

    Manage probability and impact.

  12. 12. Partition Mode as State Machine

    Detect → Decide → Recover

    Detect / Decide

    Symptoms: latency, majority, heartbeats

    Policy: fail-fast or stale

    Restrictions: read-only/degrade

    Recover

    Replica reconciliation

    Conflict resolution and compensation

    Track lag, conflicts, recovery

  13. 13. Latency Governs CAP

    Partition often starts with timeouts

    Slow networks look partitioned.

    'Wait longer' helps C.

    'Respond faster' helps A, risks C.

    Timeout/retry policy is CAP policy.

  14. 14. ACID vs CAP: Different C

    Terminology confusion breaks design

    C in ACID

    Business and schema invariants

    Balance and foreign keys

    Transactional correctness

    C in CAP

    Distributed linearizability

    Nodes see incompatible results

    Replicas and network under failure

  15. 15. BASE Answers Availability

    Soft state, eventual consistency

    Temporary inconsistency buys A.

    Soft state changes itself.

    Eventual convergence without new writes.

    A different guarantee profile.

  16. 16. Gilbert–Lynch Formal Definitions

    Why the theorem is rigorous

    C = atomic consistency.

    A: healthy node responds.

    P: arbitrary message loss.

    Read/write object cannot give A+C.

  17. 17. Asynchronous Impossibility

    Two-node contradiction proof

    Assume A + atomic C exists

    G1 and G2 lose all messages

    Write to G1, read from G2

    A needs response; C needs write

  18. 18. Partial Synchrony Doesn't Help

    Clocks do not remove CAP

    Clocks and deadlines help.

    Under message loss, A/C conflict persists.

    Timeouts detect, not remove CAP.

    Architect still chooses incident behavior.

  19. 19. CAP Takeaways for Architecture

    Describe critical operations.

    Agree on denial/degradation limits.

    Link timeouts/retries to CAP strategy.

    Prepare reconciliation and compensation processes before an incident.

    CAP is managed degradation, not a theoretical puzzle.

  20. 20. CAP: What to Do in Failure

    PACELC adds normal mode

    P-block — With partition, choose availability or consistency.

    ELSE-block — Healthy network: choose L or C.

    Why it matters — Most decisions happen in normal mode.

  21. 21. PACELC Formula

    if P then A/C else L/C

    P: availability or consistency

    ELSE: latency or consistency

    Trade-off exists always

    Explains modern databases better

  22. 22. Why PACELC Was Needed

    CAP ignores normal mode

    Partitions are rare; Cassandra is eventual.

    Answer: latency and throughput.

    Cross-region sync raises p99.

    PACELC exposes peacetime choice.

  23. 23. Latency vs Consistency in Normal Mode

    The greatest architectural pain happens right here

    Global order needs coordination

    Coordination hurts p95/p99

    Eventual/causal changes app logic.

    Compare delay cost vs read error.

  24. 24. PACELC Categories

    PA/EL, PC/EC, PA/EC, PC/EL

    A profiles

    PA/EL: A during P, L normally.

    PA/EC: A during P, C normally.

    C profiles

    PC/EC: C during P and normally.

    PC/EL: C during P, L normally.

    Formalize profile in ADRs/SLOs.

  25. 25. PA/EL: Speed and Availability First

    A typical choice for high-scale content scenarios

    During partition, responds despite temporary desync.

    Normal mode optimizes latency/throughput.

    Examples: Cassandra, DynamoDB, Riak.

    Needs app-level compensation mechanisms.

  26. 26. PC/EC: Consistency First

    When correctness beats latency

    Partition blocks some operations.

    Peacetime also favors consistency.

    Examples: Spanner-like systems.

    Domains: payments, ledger, limits.

  27. 27. PA/EC: Reliable and Strict

    A in incidents; C in normal mode

    Partition: avoid service interruption.

    Normal mode: stronger consistency.

    Depends on quorum/read concern.

    Staleness allowed only in outages.

  28. 28. PC/EL: Rare but Important Profile

    Strict during failures, fast during normal network

    Partition keeps strictness; some requests reject.

    Normal mode optimizes latency.

    Requires fine-grained routing/failover.

    Niche: strict incidents, good UX.

  29. 29. Map PACELC to Product Needs

    Not 'which DB is trendy' but 'which error is unacceptable'

    C priority

    Payments and transactions.

    Balances/limits without oversell.

    Legal journals and audit.

    L/A priority

    Feeds and recommendations.

    Search with acceptable drift.

    Near-real-time analytics.

  30. 30. Calculate Latency/Consistency Budget

    PACELC must map to team metrics

    Set p95/p99 and stale-read share.

    Separate downtime and freshness budgets.

    Write-path: latency, lag, conflict rate.

    Read-path: lagging-replica share and read-version age.

  31. 31. What PACELC Adds to CAP

    CAP: failure mode; PACELC: plus normal mode.

    Key choice is often else: L vs C.

    Category comes from business error cost and SLA.

    Validate with tests and observability.

    PACELC budgets engineering trade-offs.

  32. 32. Jepsen: Stress-Testing Distributed Systems

    From documentation to verifiable guarantees

    What it is — Kyle Kingsbury's project for correctness testing under failures.

    What it does — Generates operations, injects failures and checks history.

    Why it matters — Separates guarantees from marketing.

  33. 33. Why Architects Read Jepsen

    Bugs appear under failures

    Checks partition/crash/clock skew.

    Found lost writes and atomicity bugs.

    Vendors fix and clarify guarantees.

    Surfaces risks before adoption.

  34. 34. Jepsen's Five-Step Cycle

    Setup → Generate → Nemesis → Record → Check

    Setup: cluster and expected model

    Generate: concurrent read/write/CAS

    Nemesis: failures and anomalies

    Record + Check: find counterexamples.

  35. 35. Jepsen Failure Models

    Why 'almost correct' systems break

    Network scenarios

    Full partition between node groups.

    Asymmetric loss / one-sided visibility.

    High jitter, intermittent links.

    Process / timing

    Process or leader crash/restart.

    Clock skew / time sync drift.

    Overlapping failure scenarios.

  36. 36. Typical Jepsen Findings

    Where promises and reality diverge most often

    Lost writes during failover/split-brain.

    Read-your-writes and stale reads.

    Transaction guarantee anomalies under concurrent load.

    'Strong consistency' without a model.

  37. 37. Jepsen Model Map: Two Branches, One Apex

    Serializable (RDBMS) and Linearizable (Distributed)

    Transactional branch — Isolation and allowed anomalies.

    Distributed branch — Global read/write order.

    Apex — Strict Serializable unites both axes.

  38. 38. Serializable vs Linearizable

    Similar words, different guarantees

    Serializable

    Equivalent to serial transaction order.

    Order may ignore wall-clock time.

    Focus: isolation anomalies.

    Linearizable

    One commit point per operation.

    Order respects real completion time.

    Focus: replicated read/write.

  39. 39. Choose a Model for Product

    Guarantee should match error cost

    Eventual fits acceptable staleness.

    Causal fits user causal chains.

    Linearizable fits read/write truth.

    Strict Serializable protects invariants.

  40. 40. Overall Framework: CAP + PACELC + Jepsen

    1) Formalize invariants and unacceptable errors.

    2) Describe partition mode per operation.

    3) Choose PACELC and latency/consistency budgets.

    4) Fix the target consistency model.

    5) Validate with chaos/Jepsen before critical load.

    Experiments confirm architectural trade-offs.

  41. 41. Cassandra Through CAP/PACELC

    Bigtable + Dynamo, tunable consistency, and AP profile

    Origins — Bigtable: wide-column, LSM write path. Dynamo: hashing, gossip, peer-to-peer.

    Classification — CAP: AP. PACELC: PA/EL.

    Practice — Tunable consistency levels.

  42. 42. Cassandra Tunable Consistency

    Guarantee depends on R/W levels

    Writes: ANY, ONE, QUORUM, ALL.

    Reads: ONE, QUORUM, ALL.

    W+R>RF improves latest-read odds.

    QUORUM balances correctness/latency.

  43. 43. How Cassandra Maintains Scale and Availability

    LSM write path + token ring + repair

    Write path and storage

    Commit Log → MemTable → SSTable.

    Compaction removes old versions.

    LSM optimizes writes.

    Distribution and resilience

    Consistent hashing + vnodes.

    Gossip detector, no master.

    Repair drives convergence.

  44. 44. References and Materials

    CAP: https://system-design.space/chapter/cap-theorem

    PACELC: https://system-design.space/chapter/pacelc-theorem

    Consistency Models (Jepsen): https://system-design.space/chapter/jepsen-consistency

    Cassandra: https://system-design.space/chapter/cassandra

    All 4 source chapters from system-design.space in one place.