categories.database Intermediate

What Is the CAP Theorem? How to Apply It in System Design?

AI Practice

CAP Theorem

Three Properties

In a distributed system, you can guarantee at most two of:

  • C — Consistency: All nodes see the same data at the same time
  • A — Availability: Every request receives a response (not necessarily the latest data)
  • P — Partition Tolerance: System continues operating despite network partitions

Why Must We Choose P?

Network partitions are unavoidable in real distributed systems (failures are the norm). So the real choice is CP vs AP.

CP Systems (Consistency + Partition Tolerance)

  • Reject requests during partitions to guarantee consistency
  • Examples: HBase, ZooKeeper, traditional RDBMS

AP Systems (Availability + Partition Tolerance)

  • Still respond during partitions (may return stale data); eventual consistency
  • Examples: Cassandra, CouchDB, DynamoDB

Extension: PACELC Theorem

CAP only addresses partition scenarios; PACELC is more complete:

  • With partition: A vs C
  • Without partition (normal operation): Latency vs Consistency

Interview bonus: MongoDB can be either CP (primary-only reads) or AP (allowing reads from secondaries with stale data) depending on configuration.

✦ AI Mock Interview

Type your answer and get instant AI feedback

Sign in to use AI scoring

Copyright © 2026 Wood All Rights Reserved · FE Interview Hub