Skip to Content

Explain CAP in one sentence and a one-line memory aid.

Category: System Design

Answer

In a partition, a distributed system can’t have both consistency (every read returns the latest committed write) and availability (every request returns a non-error). You pick one; P is not optional. Memory aid: under partitions, choose C or A. CP means “stay correct, defer responses”; AP means “respond, may be stale”.

Concrete examples from the fca project context

Example 1

Consistency: linearizable reads across replicas.

Example 2

Availability: every request gets a response.

Example 3

Partition tolerance: required for any multi-node system.

Example 4

Banking -> CP (don’t show stale balance). Shopping cart -> AP (stale inventory is fine).

Data flow / flow chart

partition happens
  CP: refuse writes until partition heals
  AP: serve from local replica, stale reads possible

Takeaway

CP for “don’t lie to me” workloads (banking, inventory billing). AP for “be useful even if stale” (feeds, social).