Handbooks  /  CP vs AP Databases
Engineering~9 min readComparison
Head to Head

CP vs AP databases: what happens during a partition?

CPvsAP

This trade-off only exists during an actual network partition. The rest of the time, a well-designed system can be both consistent and available — which is why the popular "pick 2 of 3, always" version of CAP theorem is a little bit wrong.

01

The one distinction that decides everything

Rooted in CAP theorem: during a network partition, a distributed database must choose between Consistency (every read sees the latest write, but the system may refuse some requests) and Availability (every request gets a response, but it might be stale). CP systems pick consistency under a partition; AP systems pick availability. Partition tolerance itself is treated as a given — real networks partition, so it isn't the choice being made.

→ The rule

Is stale data worse than no data for this piece of state? CP. Is refusing service worse than briefly-stale data? AP. This decision is made per data type, not once for a whole system.

02

Head to head

DimensionCPAP
Under a partitionSome nodes refuse to serve rather than risk stale dataAll reachable nodes keep serving, possibly stale/conflicting data
Consistency modelStrong / linearizableEventual — reads may be stale until convergence
Example systemsZooKeeper, etcd, HBase, Spanner (with tight clock sync)Cassandra, DynamoDB (default), CouchDB, Riak
Conflict handlingPrevented by design — writes serialized via consensusAllowed, then resolved — LWW, vector clocks, CRDTs
Write availability during partitionMinority side can’t write — waits or errorsEvery reachable node accepts writes, always
Read guaranteeAlways the latest committed value, or an error — never staleMay return an outdated value, but always returns something
Best forFinancial ledgers, config stores, distributed locksShopping carts, social feeds, session data
03

When to reach for each

Reach for CP

  • Correctness of the value matters more than uptime
  • Bank balances, distributed locks, leader election
  • Inventory counts where overselling is a real cost
  • Config that must never diverge across nodes

Reach for AP

  • Uptime matters more than perfect freshness
  • A briefly-stale shopping cart or feed is fine
  • Refusing service would be worse than serving old data
  • Per-query tunable consistency is available (quorum reads/writes)
04

Most real systems pick per data type, not once

The CP/AP label rarely applies uniformly across a whole product. An e-commerce platform commonly runs the shopping cart AP (a brief hiccup shouldn't block adding an item) and the final checkout/inventory-decrement CP (that specific write genuinely can't tolerate a stale double-sell). Many "AP" systems like Cassandra also let you tune consistency per query via quorum settings — meaning the CP/AP label often describes a DEFAULT or an extreme end of a dial, not a permanent, unchangeable binary choice.

→ The practical shape

Ask the question per piece of state, not per system: "if this specific write is briefly unavailable during a partition, is that better or worse than it being briefly wrong?"

05

This trade-off only bites during an actual partition

It's worth being precise about what CAP theorem actually constrains, because it's commonly overstated. The forced choice between consistency and availability applies ONLY during an actual network partition — nodes genuinely unable to reach each other. Most of the time, with no partition happening, a well-designed system can be both consistent and available simultaneously; there's no theorem forcing a permanent sacrifice of one for the other in normal operation. The popular shorthand "pick 2 of 3, always" is a mis-simplification of a narrower, more useful statement: partitions WILL eventually happen in any real distributed system — that part isn't optional or a choice you get to avoid by careful engineering — and CAP describes the forced choice you must make specifically for the DURATION of that partition, not a permanent architectural ceiling you live under forever.

This precision matters practically: a system doesn't need to decide "I am a CP system" or "I am an AP system" as an eternal identity — it needs to decide, for each piece of state, what should happen in the specific window where nodes can't talk to each other. That's a much narrower, more answerable design question than the theorem's popular framing suggests.

→ The trade you’re actually making

You're not choosing consistency or availability forever — you're pre-deciding what a specific piece of data should do during the finite window of an actual partition, which is a much smaller and more tractable decision than it sounds.

06

A worked scenario: cart vs checkout on the same platform

An e-commerce platform's shopping cart service is built AP (Cassandra/DynamoDB-style): if a data-center link partitions, the cart keeps accepting adds and removes on both sides of the partition and reconciles later — refusing to let someone add an item during a brief network hiccup would just lose a sale for no real benefit, since a cart being briefly inconsistent across replicas costs nothing serious.

The SAME platform's checkout-time inventory decrement is built CP, routed through a strongly-consistent store or leader — because during that same partition, letting both sides independently decrement the last unit of a sold-out item would double-sell it, a real, costly correctness failure. Refusing the write until consistency is restored — telling some users "try again" — is the correct trade here, even though it's the opposite choice the cart made one service over. Same platform, same partition event, two deliberately different answers.

→ The pattern generalizes

The question was never "is this platform CP or AP" — it was "for this specific write, is stale worse than unavailable," asked and answered separately for the cart and for the inventory decrement.

Frequently asked

Quick answers

CP or AP — which should I use?

Decide per data type: if stale data is worse than no data (financial balances, distributed locks, inventory counts), choose CP. If refusing service is worse than briefly-stale data (shopping carts, feeds, session state), choose AP. Most real systems use both, for different pieces of state.

Does CAP theorem mean I always sacrifice consistency or availability?

No — the forced trade-off only applies during an actual network partition. Without a partition, a well-designed system can be both consistent and available. The theorem describes the choice you must make for the duration of a partition, not a permanent limitation.

Can a system be both CP and AP?

Not for the same piece of data during a partition — but a single system commonly runs different services or data types with different CP/AP choices (e.g. an AP cart and a CP checkout), and many AP systems let you tune consistency per query via quorum settings.

What happens to a CP system during a partition?

The minority side of the partition (the side that can’t confirm it has the latest state via consensus) refuses to serve some requests — typically writes, sometimes reads — rather than risk returning or accepting a value that could conflict once the partition heals.

CP vs AP Databases · Vibe Engines · 2026
Finished this one? 0 / 115 Handbooks done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.