The Three Properties

C — Consistency

Every read receives the most recent write, or an error. Every node in the distributed system sees the same data at the same time. If you write a value to node A and immediately read from node B, you get that same value.

Example: You transfer $1,000 from your savings account. If the system is consistent, checking your balance immediately from any region shows $1,000 less. If it is inconsistent, some nodes might still show the old balance.

A — Availability

Every request receives a response (not an error), though the response might not contain the latest data. The system is always up and responsive — no node refuses requests.

Example: Even if some database nodes are unreachable, the remaining nodes continue serving reads and writes without returning errors.

P — Partition Tolerance

The system continues to operate even when network partitions occur — when some nodes cannot communicate with others due to network failures.

Why P is mandatory: In any real distributed system spanning multiple machines or datacenters, network partitions are not hypothetical — they happen. Switches fail, cables are cut, datacenter links drop. A system that cannot tolerate partitions is not a distributed system — it is a single-node system.

The Impossible Triangle

Consistency (C) /\ / \ / \ / CA \ / (single\ / node) \ /____________\ CP / \ AP (consistent, / Choose \ (available, may error) / 2 of 3 \ may be stale) /____________________\ Partition Tolerance (P) (always required) Real choice (P is mandatory): CP: Consistency + Partition Tolerance AP: Availability + Partition Tolerance

When a network partition occurs, a distributed system must choose:

  • CP choice: Stop accepting writes (or return errors) to maintain consistency. Nodes that cannot confirm the write with a majority refuse to serve requests. The system is consistent but unavailable during the partition.
  • AP choice: Continue serving reads and writes from all available nodes, accepting that different nodes may have different (stale) data until the partition heals and they synchronise.

CP Systems — Consistency Over Availability

CP systems prioritise returning correct, consistent data. During a network partition, they refuse to serve requests (return errors or timeouts) rather than risk returning stale data.

  • HBase: Uses HDFS, strict consistency, refuses writes if region server is unavailable
  • Zookeeper: Coordination service — must be consistent for distributed locks and leader election
  • etcd: Kubernetes uses etcd for cluster state — must be consistent or cluster misbehaves
  • MongoDB (default): With majority write concern, refuses writes that cannot reach a majority of replica set nodes
CP behaviour during partition Node A and Node B are partitioned (cannot communicate) Client writes to Node A: "user balance = $500" Client reads from Node B: ERROR — "Cannot guarantee consistency" or TIMEOUT — node B refuses to respond Result: consistent (no stale data returned) but unavailable Use when: bank balance, inventory count, distributed locks

AP Systems — Availability Over Consistency

AP systems prioritise always returning a response. During a partition, all nodes remain available and accept reads/writes — but different nodes may have different data until the partition heals.

  • Cassandra: All nodes accept writes; eventual consistency with tunable consistency level (ONE, QUORUM, ALL)
  • DynamoDB (default): Eventually consistent reads — may return slightly stale data for lower latency
  • CouchDB/Couchbase: Multi-master replication — all nodes accept writes, conflicts resolved later
  • DNS: Updates propagate gradually — you might get stale IP for hours (TTL-based eventual consistency)
AP behaviour during partition Node A and Node B are partitioned (cannot communicate) Client writes to Node A: "user balance = $500" — ACCEPTED Client reads from Node B: "user balance = $600" — stale data returned After partition heals, nodes sync and converge to consistent state Result: available (always responds) but may return stale data Use when: social media likes, shopping cart, user profiles, DNS

Real Database CAP Classification

DatabaseCAP ClassConsistency ModelNotes
PostgreSQL (single node)CAACID, strong consistencyNot partition tolerant by design
MySQL (single node)CAACID, strong consistencySame as PostgreSQL
MongoDBCP (default)Tunable: majority or localCan tune to AP with w:0
CassandraAPEventual (tunable per-query)QUORUM = stronger consistency
DynamoDBAP (default)Eventual or strong (extra cost)Strong consistency opt-in
HBaseCPStrong consistencyBuilt for consistent reads
Redis (single)CAStrong in memoryRedis Cluster is CP
etcdCPRaft consensus — linearizableUsed by Kubernetes
CouchDBAPEventual, MVCCMulti-master replication
ZookeeperCPSequential consistencyLeader-based writes

Beyond CAP — The PACELC Theorem

CAP only addresses behaviour during partitions. The PACELC theorem (Daniel Abadi, 2012) extends it: Partition → choose Availability or Consistency; Else (no partition) → choose Latency or Consistency.

Even without partitions, there is a trade-off: strong consistency requires synchronous replication (waiting for all nodes to confirm writes) = higher latency. Low latency requires asynchronous replication = potential inconsistency window.

DatabasePartition (CAP)Normal (ELC)
DynamoDBPAEL (low latency, eventual)
CassandraPAEL (low latency default)
MongoDBPCEC (consistency)
PostgreSQLPC (in cluster)EC (consistency)

Practical Guidance

For financial data, inventory, and anything requiring correctness: choose CP (PostgreSQL, MongoDB with majority writes, HBase). For user-facing data where slight staleness is acceptable and global availability matters more than perfect consistency: choose AP (DynamoDB, Cassandra). Most applications actually need a mix — use CP for financial transactions and AP for activity feeds, recommendations, and counters.

CAP Is a Theoretical Model with Nuances

The original CAP theorem deals with binary choices under worst-case network partitions. Real systems offer tunable consistency — Cassandra lets you choose ONE/QUORUM/ALL per query. Modern databases (Spanner, CockroachDB) use clock synchronisation and consensus algorithms to provide strong consistency with wide availability, challenging the traditional CAP framing. CAP is a useful mental model, not a rigid constraint.

How We Research and Update This Guide

We test the underlying formula or workflow, compare outputs with reliable references, and revise examples whenever the page content changes.

  • The workflow or formula is tested directly in the tool and compared against independent reference examples.
  • Examples are kept practical so readers can verify the result without hidden assumptions.
  • Pages are revised whenever the interface, calculation flow, or surrounding guidance materially changes.

Frequently Asked Questions — CAP Theorem