Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/CAP Theorem & PACELC
DISTRIBUTED SYSTEMS & ARCHITECTURE · SUBTOPIC

CP vs. AP Under Network Partitions

Decide when a service should return an error rather than stale data.

IntermediatePart of CAP Theorem & PACELC
Practice in AI HLD
Subtopics in CAP Theorem & PACELC (2)
OverviewCP vs. APPACELC Theorem

In plain words

If two bank tellers lose phone contact with each other, a CP bank stops withdrawals until the line comes back so nobody spends the same $100 twice. An AP coffee punch-card shop keeps stamping cards and totals them up later.

Think of it like…

ATM refusing cash when offline (CP) vs. airplane tablet taking offline snack orders and syncing after landing (AP).

Loading interactive diagram
Loading interactive exercise

Theory & how it works

Mixing CP and AP inside one product

An e-commerce app isn’t purely CP or AP: product catalog & reviews are AP (keep showing pages even if stale by 5s), while checkout & inventory deduction are CP (never sell the last concert ticket twice).

Key points & practical guide

Summary checklist

  • Partitions (P) are inevitable in distributed systems
  • CP sacrifices availability on the minority partition
  • Split a single app into CP and AP subsystems by criticality

When to use it

  • CP for balances, seats, unique usernames, locks
  • AP for feeds, caches, likes, analytics

Watch out for

  • Claiming a distributed database is "CA" across regions - CA only exists on a single non-partitioned machine

Quick check

Loading quiz
Parent topic
CAP Theorem & PACELC
Next subtopic
PACELC: Latency vs. Consistency