Knowledge Guide
HomeSystem DesignScalable Systems (Advanced Topics)

hard CAP/PACELC for Replication & Reads

Replication is a consistency decision, not just a scaling knob

CAP says that during a network Partition you must give up either Consistency or Availability — you cannot keep both. PACELC completes the sentence for the common case: if Partitioned, choose A or C; Else (normal operation) choose Latency or Consistency. The moment you add a replica, you have taken a PACELC stance whether you meant to or not, because when the write reaches the replica is the whole question.

A client writes name=Alice to the primary and is acked; 50ms later it reads from a replica that lags by 200ms, so the read returns the old name and misses the client's own write
A client writes name=Alice to the primary and is acked; 50ms later it reads from a replica that lags by 200ms, so the read returns the old name and misses the client's own write

Traced anomaly: reading your own write and missing it

Async replication, replica lag ≈ 200ms, reads load-balanced across primary and replica.

tActionWhat the user sees
t0User sets display name to “Alice” → write to primary
t0+2msPrimary commits and acks; change starts replicating“Saved!”
t0+50msPage reloads; read is routed to a replica still 150ms behindold name — looks like the save was lost
t0+200msReplica finally applies the changecorrect on next read

Nothing is broken and no data is lost — the write is safely committed on the primary. The user simply read from a replica that hadn’t caught up. This is a read-your-writes violation, and it is the most common “the app feels buggy” symptom of async read replicas.

Fixes (buy back just enough consistency)

Pitfalls

The judgment layer

Synchronous (CP/EC) vs asynchronous (AP/EL). Choose synchronous when a stale read is a correctness bug — account balances, inventory counts, permission checks, anything a user edits and immediately re-reads — and you can afford the extra write latency and the risk of blocked writes when a replica is down. Choose asynchronous when the workload is read-heavy and latency-sensitive and bounded staleness is acceptable — social feeds, product catalogs, analytics — and patch the sharp edges (read-your-writes, monotonic reads) surgically rather than making every read consistent. In PACELC terms: Cassandra/Dynamo are PA/EL (available and fast, tunable toward consistency per query); Google Spanner and HBase are PC/EC (they hold consistency and pay the latency). The lens forces the question out into the open: what does this specific read do if it’s 200ms stale?

Takeaways


Synthesized from Gilbert & Lynch (CAP proof), Daniel Abadi’s PACELC formulation, and Kleppmann, Designing Data-Intensive Applications (Ch. 5, replication lag and read-your-writes / monotonic reads). Re-authored/Deepened for this guide.

🤖 Don't fully get this? Learn it with Claude

Stuck on CAP/PACELC for Replication & Reads? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **CAP/PACELC for Replication & Reads** (System Design) and want to truly understand it. Explain CAP/PACELC for Replication & Reads from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **CAP/PACELC for Replication & Reads** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **CAP/PACELC for Replication & Reads** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **CAP/PACELC for Replication & Reads** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes