Skip to main content
PreparationZone Logo
PrepZone

CAP and PACELC Trade-offs

Consistency vs availability under partitions — the database engineer's lens.

Pass checkpoint below

Why this matters

  • Mislabeling a store as "CP" or "AP" in interviews signals shallow understanding — real systems tune per operation.
  • Production incidents during regional outages expose whether your consistency choices match user expectations.
  • VaultCommerce runs CP-ish Postgres for money and AP-ish caches for browse — the mix is deliberate.
App writesINSERT / UPDATE
LeaderPrimary node
Replica 1Read traffic
Replica 2Read traffic
Writes go to the leader; replicas serve read traffic asynchronously.

CAP in plain terms

CAP components

  • Consistency (C) — every read returns the latest write (linearisable).
  • Availability (A) — every request gets a response, even if not the freshest.
  • Partition tolerance (P) — the system continues despite network splits between nodes.

When nodes cannot talk (partition), you must sacrifice C or A. In practice, partitions happen — datacenter links fail, AZs isolate, misconfigured firewalls drop packets.

Java
Partition between EU and US replicas:

CP choice: reject reads/writes until quorum confirms leader
  → VaultCommerce payment service returns 503 (unavailable but consistent)

AP choice: serve stale data from local replica
  → VaultCommerce product browse shows yesterday's price until healed

PACELC — the everyday trade-off

If Partition, choose A or C; Else, choose Latency or Consistency.

Most of the time there is no partition — you still choose how fresh reads must be versus how fast they return.

AspectLatency-first (EL)Consistency-first (EC)
Typical storeDynamoDB (eventual), Cassandra (ONE)Postgres primary, etcd
Read behaviourLocal replica, may be staleQuorum or primary, fresher
VaultCommerce pathRecommendation feed, search facetsCheckout, inventory hold
User-visible riskStale banner, wrong countSlower page, occasional 503
  • Typical store

    Latency-first (EL)DynamoDB (eventual), Cassandra (ONE)
    Consistency-first (EC)Postgres primary, etcd
  • Read behaviour

    Latency-first (EL)Local replica, may be stale
    Consistency-first (EC)Quorum or primary, fresher
  • VaultCommerce path

    Latency-first (EL)Recommendation feed, search facets
    Consistency-first (EC)Checkout, inventory hold
  • User-visible risk

    Latency-first (EL)Stale banner, wrong count
    Consistency-first (EC)Slower page, occasional 503

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 3 sections

  • Tunable consistency in practice
  • Mapping stores to CAP/PACELC
  • Designing for your consistency budget

Test yourself

Answer these before moving on — recall is what makes it stick.