Skip to content
Dev Dump

⚖️ CAP Theorem Explained

GuaranteeDefinitionNotes
ConsistencyEvery read returns the most recent write (or errors).Differs from ACID consistency; refers to linearizable reads.
AvailabilityEvery request receives a non-error response, regardless of staleness.Clients always get a reply.
Partition ToleranceSystem continues operating despite message loss or delays between nodes.Realistic distributed systems must assume partitions.

Core Guarantees

CombinationWhat you keepWhat you sacrificeTypical Systems
CPConsistency + Partition toleranceAvailabilityBanking, stock trading, critical configuration stores
APAvailability + Partition toleranceConsistencySocial feeds, DNS, shopping carts
CAConsistency + AvailabilityPartition toleranceOnly feasible in single-node or tightly coupled clusters
  • Consistency-first: three-node cluster requires acknowledgements from all nodes before serving reads. On partition, isolated nodes reject requests.
  • Availability-first: nodes continue serving reads/writes locally even when disconnected, accepting stale data for uptime.
  • Partition tolerance: regardless of strategy, the cluster keeps functioning in the presence of lost or delayed messages.
LevelDescriptionUse CasesExample Technologies
Weak consistencyNo guarantees on reads; best effort replication.Realtime media streams, gaming.VOIP, multiplayer servers.
Eventual consistencyData converges over time; replicas sync asynchronously.Social apps, DNS, email.DynamoDB, Cassandra, DNS.
Strong consistencyReads always reflect the latest writes; synchronous replication.Financial systems, ledgers.RDBMS, ZooKeeper, Spanner (with scoped latency).

Consider a system with three nodes (A, B, C):

  • All nodes (A, B, C) maintain the same data
  • When B updates data, it must propagate to A and C
  • System ensures all nodes show same data or returns error
  • If node B fails, A and C continue operating
  • System keeps responding to requests
  • May not have most recent data
  • Network partition separates B from A and C
  • System continues functioning despite partition
  • May sacrifice either consistency or availability