Architecture Expert
CAP Theorem in Practice¶
CAP TheoremDistributedConsistency 3 min read
Practical implications of the CAP theorem on system design. CP vs AP systems.
CP vs AP¶
- CP — consistency + partition tolerance. ZooKeeper, etcd, MongoDB
- AP — availability + partition tolerance. Cassandra, DynamoDB, CouchDB
Decision Making¶
CP: Banking transactions, limited goods inventory, lock management.
AP: Social media feed, product catalog, analytics, shopping cart.
Practical Examples¶
In practice, you rarely choose strictly between CP and AP — most modern systems offer configurable consistency models. For example, MongoDB defaults to CP behavior with majority read/write concern, but you can switch it to AP behavior by lowering concern to local. Cassandra, on the other hand, defaults to AP, but with QUORUM consistency level it behaves as CP.
It is important to understand that the CAP theorem only applies during a network partition. When the network is functioning correctly, most databases provide both consistency and availability. Therefore, it is more practical to think in terms of the PACELC model: during a Partition you choose A or C, otherwise (Else) you choose Latency or Consistency. For example, DynamoDB is PA/EL — during partition it prefers availability, otherwise low latency.
Summary¶
CAP influences every architectural decision. Make conscious trade-offs for each bounded context.
Need Help with Implementation?¶
Our team has experience designing and implementing modern architectures. We’re happy to help.