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
System Design topics
Lesson 15/ 31
Distributed Systems & Architecture

CAP Theorem & PACELC

Choose clearly between consistency and availability when network links inevitably split.

IntermediateCP vs AP · PACELC3 quiz questions0/2 subtopics done
Practice in AI HLD
In plain wordsDiagramTheorySubtopics (2)Step by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice
Deep-dive subtopics (2) - 0/2 completed
CP vs. AP Under Network Partitions

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

Intermediate
PACELC: Latency vs. Consistency

Understand why you pay a consistency-vs-latency trade-off even when nothing is broken.

Intermediate

In plain words

When the network between servers breaks, a distributed system must choose: refuse some requests to stay correct, or keep answering with possibly stale data. CAP names that trade-off.

Think of it like…

Two bank tellers lose phone contact: either they freeze withdrawals until the phone works (CP) or let customers withdraw from stale balances and reconcile later (AP).

Where you’ve seen it

During a network split, a bank prefers to reject a transfer rather than risk a wrong balance (consistency). A shopping cart prefers to keep working and fix conflicts later (availability).

Words you’ll hear

Consistency
Every read sees the latest write.
Availability
Every request gets a response, even during failures.
Partition
A network break that stops some servers from talking to others.
PACELC
Even without a partition, you still trade latency against consistency.

Visual diagram

Loading interactive diagram
Loading interactive exercise

Theory & deep dive

What CAP actually says (and the common myth)

People often say "pick any 2 of Consistency, Availability, Partition Tolerance." In reality, you cannot opt out of network partitions - fiber cables get cut and switches reboot. So when a partition happens (P), you must choose between Consistency (C) and Availability (A).

And PACELC adds the everyday reality when the network is healthy (Else): you STILL choose between Latency (L) and Consistency (C) - waiting for cross-region replicas slows writes down, while returning immediately risks stale reads.

Key takeaway: CAP governs failure (CP vs AP); PACELC governs normal days too (Latency vs Consistency).

How it works, step by step

Step 1 of 4
Network Reality

1. Recognize that partitions (P) are non-optional

Switches drop packets, cross-AZ fibers get cut, and GC pauses look identical to dead links. A distributed store must always tolerate P.

Real distributed choice during outage: CP or AP
Key numbers at this step
Partition Cause
Link cut / GC pause
CA Systems
Single-node only

When to use it & trade-offs

What it is

CAP states that during a network partition (P), a distributed data store must choose between linearizable Consistency (C) and 100% Availability (A). PACELC extends this: even without partitions (E), you still trade Latency (L) vs. Consistency (C).

Why it matters: Network partitions always happen in real clusters, so “CA” is impossible for distributed systems - you must decide per feature whether stale data or an error is safer.

When to reach for it

  • CP for money transfers, ticket holds, auth token revocation, and leader election
  • AP for timeline caches, product descriptions, likes/views, and collaborative drafts (with CRDTs)
  • Mixing both in one product: CP for checkout, AP for product catalog browsing

When to avoid or be careful

  • Claiming a distributed database is “CA” (single-node DBs aren’t partition-tolerant; distributed ones must handle P)
  • Applying one blanket CAP label to an entire app instead of per data domain

CP vs. AP & PACELC Profiles

CP (Consistency + Partition Tolerance)
Best for: Financial balances, distributed locks, seat/ticket inventory

Strengths: Every successful read sees the latest committed write; no split-brain corruption.

Watch out: Minority nodes reject requests during partitions; synchronous quorum adds write latency.

AP (Availability + Partition Tolerance)
Best for: Social feeds, view counters, DNS, shopping carts, telemetry

Strengths: High uptime and low latency even across flaky cross-region links.

Watch out: Clients may observe stale reads or concurrent write conflicts that need resolution.

PACELC: PA/EL vs. PC/EC
Best for: Tuning steady-state latency vs. cross-node sync

Strengths: Clarifies that even without outages, quorum/sync writes cost extra network RTT.

Watch out: Must explicitly pick which endpoints (e.g., checkout vs. browsing) pay the latency cost.

Interview signals & numbers to know

When this topic comes up

  • network partition
  • split brain
  • strong consistency vs availability
  • multi-region
  • inventory

Benchmarks & rules of thumb

Quorum formula -
W + R > N
Typical quorum (N=3) -
W=2, R=2
Same-region quorum RTT -
~0.5–2 ms
Cross-region quorum RTT -
~50–150 ms

Common mistakes & follow-ups

Common interview mistakes

  • Saying “we pick CA because our AWS network is reliable” - partitions still happen in every cloud
  • Treating CAP as binary across the whole app rather than per subsystem (checkout = CP, catalog = AP)
  • Forgetting PACELC: in normal operation, you still trade latency for consistency

Likely interviewer follow-ups

  • Why is a “CA” distributed system considered impossible in practice?
  • How does PACELC refine CAP for healthy networks?
  • In an e-commerce site, which subsystems should be CP and which can be AP?
Interview tip: Break the system down by feature: say “checkout/inventory is CP, while product browsing and reviews are AP”.

Knowledge check

Loading quiz

Put it into practice

Design full architectures with AI feedback

Apply CAP Theorem & PACELC inside real High-Level Design prompts or review Q&A flashcards.

Open AI HLD Practice →SD Interview Q&A
Previous topic
Data Warehousing & Lakes
Next topic
Consistency Models