Eventual Consistency
1. Executive Summary
Eventual consistency is a liveness-oriented guarantee for replicated systems: if updates stop and no new failures occur, all replicas will converge to the same value. During convergence, different clients may observe divergent states. Unlike linearizability, eventual consistency does not promise a single real-time order of operations—it promises that safety of convergence emerges when the system quiesces.
The model is central to the CAP theorem (Brewer conjecture; Gilbert & Lynch proof): under network partition, a system cannot simultaneously provide linearizable consistency and availability for all operations. Eventual consistency is the characteristic choice on the availability side of that tradeoff—Dynamo, Cassandra, Riak, DNS, and CDN caches all embody variants of "replicate now, reconcile later."
This chapter defines eventual consistency formally and informally, distinguishes safety (no permanent divergence after quiescence) from temporary anomalies (stale reads, write conflicts), covers convergence mechanisms (anti-entropy, read repair, gossip), operational and product implications, and principal-level decision criteria. Kleppmann (DDIA) and the Dynamo paper remain the canonical engineering references; Herlihy & Wing provide the contrast via linearizability as a stronger safety condition.
2. Why This Topic Matters
Most large-scale consumer and internet systems are eventually consistent somewhere in the stack—even when marketing claims "strong consistency" at one layer. Principal architects must:
- Explain what users can observe during inconsistency windows (stale reads, lost updates if misconfigured).
- Design compensating mechanisms: idempotency, version vectors, CRDTs, sagas, and explicit conflict resolution.
- Map CAP and PACELC to business requirements—not as slogans but as partition and latency behavior.
- Avoid treating eventual consistency as "no consistency"—it is a defined guarantee with convergence obligations.
Interview failures include: assuming eventual consistency fixes itself without protocols, confusing it with causal consistency, or unable to quantify RPO/RTO and staleness SLOs for AP systems.
3. Problems Being Solved
| Problem | Strong consistency pain | Eventual consistency approach |
|---|---|---|
| Regional partition | Unavailable writes/reads | Continue serving; reconcile later |
| Write latency at global scale | Quorum + commit wait | Local write ack; async replicate |
| Peak traffic spikes | Leader bottleneck | Multi-master, local replicas |
| Cache and CDN freshness | Expensive invalidation | TTL + eventual propagation |
| Offline/mobile clients | Cannot reach leader | Local queue; sync on reconnect |
| Cost of coordination | Expensive consensus clusters | Gossip, hinted handoff, repair |
Eventual consistency solves availability and latency under partition and scale. It does not solve immediate global agreement—applications must tolerate or mask interim divergence.
4. Assumptions and System Model
Assume partial failure, asynchronous network, and crash-stop replicas unless noted:
- Replicas hold copies of data; writes may be accepted at one or many replicas.
- Replication may be asynchronous; acknowledgments do not imply all replicas updated.
- Quiescence: No new writes for sufficient time; all pending replication and repair complete.
- Convergence function: After quiescence, all replicas return the same value for a given key (policy-dependent: last-writer-wins, merge, CRDT state).
CAP framing (Gilbert & Lynch): In a partition, CP systems sacrifice availability for linearizable behavior; AP systems remain available for operations but sacrifice strong consistency—typically eventual consistency with conflict handling.
Not assumed: Automatic conflict-free semantics without application or datatype support; bounded staleness unless explicitly added (e.g., session guarantees, CRDTs).
5. Essential Terminology
| Term | Definition |
|---|---|
| Eventual consistency | If no new updates, all replicas eventually agree on value. |
| Staleness | Read returns older value than another replica or than a prior acknowledged write. |
| Convergence | Process by which replicas reach identical state. |
| Anti-entropy | Background comparison and repair between replicas (Merkle trees, full scans). |
| Read repair | Repair divergent replicas during read path when versions differ. |
| Hinted handoff | Temporary redirect of writes when replica down; replay on recovery (Dynamo). |
| Sibling / conflict | Concurrent versions detected via vector clocks; require merge. |
| LWW (last-writer-wins) | Resolve conflicts by timestamp—implementation choice, can lose data. |
| AP system | Available + Partition-tolerant; typically eventual consistency. |
| PACELC | If Partition: A vs C; Else: Latency vs Consistency (Abadi, 2012). |
| Read-your-writes | Session guarantee stronger than pure eventual—client sees own writes. |
Mnemonic: Eventual = eventually the same, not always the same now.
6. Core Mechanism
Informal guarantee
For each data item:
- Replicas may diverge after concurrent or partitioned writes.
- Replication and repair propagate updates.
- When updates cease and repairs complete, all replicas return identical content per the system's resolution policy.
Convergence pathways
Figure 1: Write accepted at one replica; async replication plus repair paths drive eventual convergence.
CAP partition behavior
Figure 2: Under partition, AP systems accept writes on both sides; convergence required after heal. CP systems reject operations.
Version metadata and conflicts
Figure 3: Concurrent writes create siblings; eventual consistency requires a merge policy—not silent data loss.
7. Step-by-Step Walkthrough
Scenario: Dynamo-style shopping cart across three nodes (N=3, W=1, R=1 for availability).
| Step | Event | State | Client observation |
|---|---|---|---|
| 1 | Client writes cart to N1 | N1 has v1; N2,N3 stale | Write ack fast |
| 2 | Client reads from N2 | N2 stale | Stale read—empty cart |
| 3 | Read repair triggered | N2 updated from N1 | — |
| 4 | Client re-reads N2 | v1 visible | Converged for this key |
| 5 | Partition isolates N3 | N3 receives divergent write v2 | Divergence |
| 6 | Partition heals | Anti-entropy compares VV | Siblings if concurrent |
| 7 | Application merge | Union cart policy | Convergence with semantics |
Insight: Step 2 is not a violation of eventual consistency—it is expected before convergence. Product must handle staleness (UI refresh, versioning) or tighten W/R (higher latency, less availability).
8. Invariants and Guarantees
| Property | Type | Statement |
|---|---|---|
| Eventual convergence | Safety (asymptotic) | Quiescent system → all replicas agree |
| Availability during partition | Liveness (AP) | Some operations complete despite partition |
| Immediate consistency | Not guaranteed | Stale reads possible |
| Conflict freedom | Not guaranteed | Concurrent writes need policy |
| Durability | Separate dimension | Depends on W, fsync, quorum ack |
| Monotonicity | Optional session guarantee | Not inherent to eventual |
Safety vs liveness: Eventual consistency is a weak safety claim about the limit of execution, not about intermediate states. Lost updates are safety violations of application invariants, not of eventual consistency itself—often caused by LWW without proper versioning.
9. Failure Scenarios
Scenario 1: Permanent divergence without repair
Setup: Replica permanently lost; no replication factor replacement; W=1.
Effect: Safety violation of convergence—quiescent system still disagrees.
Mitigation: Replication factor, replacement, monitoring replica health, W>1 when needed.
Scenario 2: LWW clock skew
Setup: Two regions write same key; EU clock ahead of US.
Effect: EU write wins always—data loss of US writes.
Mitigation: Logical clocks, version vectors, CRDTs, avoid wall-clock LWW across regions.
Scenario 3: Sibling explosion
Setup: High write concurrency; vector clocks grow; no merge.
Effect: Reads return growing sibling lists; latency and storage blow up.
Mitigation: Prune policy, CRDT migration, partition keys to reduce conflicts.
Scenario 4: Read repair amplification
Setup: Hot key; every read triggers cross-replica repair.
Effect: Liveness degradation—repair storm, latency spikes.
Mitigation: Probabilistic read repair, dedicated anti-entropy, raise R selectively.
Scenario 5: "Eventually" never arrives
Setup: Continuous writes; backlog; under-provisioned replication.
Effect: System never quiesces; replicas chronically stale.
Mitigation: Capacity planning, lag SLOs, backpressure.
10. Performance Characteristics
| Dimension | Eventual (AP) | Strong (CP) |
|---|---|---|
| Write latency | Often local/one replica | Quorum + leader RTT |
| Read latency | Local replica | Leader or sync read |
| Throughput | High multi-master | Leader bounded |
| Tail latency | Repair spikes | Consensus tails |
| Partition behavior | Serves requests | Errors/timeouts |
Qualitative: eventual consistency optimizes normal-case latency and availability; pays complexity and anomaly cost in application layer. Do not cite universal staleness bounds without measured replication lag.
11. Scalability Limits
- Conflict rate: Scales inversely with merge complexity—hot keys don't scale with naive multi-master.
- Metadata: Vector clocks O(replicas) per object—bounds sibling detection cost.
- Repair bandwidth: Anti-entropy full scans don't scale to petabytes without incremental/Merkle approaches.
- Cognitive scale: Teams must reason about anomalies—organizational limit.
When eventual consistency scales well: Read-heavy, low conflict, tolerate staleness (social likes, view counts with approximation).
When it struggles: Financial balances, inventory without reservation, global uniqueness constraints.
12. Operational Considerations
- Define staleness SLOs: p99 replication lag, not just "eventual."
- Monitor: Replica lag, repair rate, sibling count, hinted handoff queue depth.
- Runbooks: Partition heal procedures; conflict merge escalation; replica replacement.
- Client contracts: Document AP behavior; retries with idempotency keys.
- Chaos testing: Partition tests before production; verify convergence time bounds empirically.
13. Security Considerations
- Conflict injection: Attacker writes divergent versions on partitioned replica—merge policy must not privilege attacker (e.g., unsigned LWW).
- Stale read information leakage: Low-security replica in wrong region—consistency interacts with data residency.
- Repair paths: Anti-entropy must authenticate peers; otherwise poisoned state spreads.
- Availability vs abuse: AP systems stay up under DDoS—rate limiting still required.
Eventual consistency does not weaken authentication; it complicates integrity during divergence windows.
14. Cost Considerations
- Infrastructure: More replicas, cross-region bandwidth for repair vs fewer strongly consistent clusters.
- Engineering: CRDT design, merge UX, testing concurrent histories—higher than "single primary SQL."
- Incident cost: Subtle bugs (stale config rollout) expensive to debug without version metadata.
- Revenue: Availability during partition may outweigh temporary inconsistency for some products.
Decision criterion: Choose eventual when downtime cost and latency SLO dominate immediate global correctness.
15. Production Implementations
Amazon Dynamo (2007)
Quorum-configurable N, R, W; vector clocks; hinted handoff; read repair—canonical AP design. DeCandia et al. explicitly trade consistency for availability. Modern DynamoDB differs—product evolution; read AWS docs for current models.
Apache Cassandra
Tunable consistency per query (ONE, QUORUM, etc.); eventual by default at low levels; LWW on cells unless lightweight transactions (Paxos)—different mechanism, higher cost.
Riak
Vector clocks and siblings; operational lessons on sibling proliferation informed later designs.
DNS and CDNs
Extreme eventual consistency—TTL-driven; global convergence on the order of minutes acceptable.
CouchDB / Cloudant
Multi-master replication with revision trees; conflicts explicit in document _rev.
Distinction: Implementation choices (W=1 vs W=quorum) change durability and staleness without changing the broad AP label.
16. Alternatives and Tradeoffs
| Model | Partition behavior | Client anomalies | Complexity |
|---|---|---|---|
| Eventual | Available | Stale, conflicts | Repair + merge |
| Causal | Available (often) | No causal violations | Vector metadata |
| Linearizable | Unavailable or degraded | None (scoped) | Consensus |
| Strong session | Available with routing | Reduced for one client | Sticky + versions |
| CRDT | Available | Algebraic merge | Datatype design |
PACELC: Without partition, still choose latency vs consistency (e.g., Cassandra LOCAL_ONE vs QUORUM).
17. Common Misconceptions
| Misconception | Reality |
|---|---|
| "Eventual = inconsistent forever" | Converges when quiescent if repair works. |
| "No consistency" | Weak but defined limit behavior. |
| "CAP means pick 2 of 3 always" | Partition-specific tradeoff; normal case differs. |
| "Read repair fixes everything synchronously" | Probabilistic; may lag. |
| "AP can't lose data" | W=1, LWW, and partitions can lose or hide writes. |
| "Same as causal consistency" | Causal is strictly stronger on happens-before. |
18. Principal Architect Perspective
- Quantify "eventual": Minutes vs milliseconds changes architecture acceptance.
- Own merge semantics: Infrastructure can't guess business merge for cart, calendar, or inventory.
- Partition drills: AP value only if you stay up safely enough—define "safely."
- Educate product: Users may see stale UI—design feedback loops.
- Layer guarantees: CDN eventual + DB strong is valid—state each layer's model.
Executives hear "eventual" as "broken." Translate to availability during failure and convergence SLO.
Convergence budgeting: Treat replication lag like a queue with a service-level objective. Measure p50/p99 lag per replica set; during incidents, lag spikes are often the first sign that "eventual" is stretching into user-visible minutes. Capacity plans should include repair bandwidth, not only write throughput—anti-entropy and read repair compete for the same cross-AZ links as foreground traffic. Kleppmann (DDIA) recommends making staleness and conflict behavior explicit in API contracts so client teams implement retries, versioning, and UI refresh against documented bounds rather than assuming instantaneous global agreement.
19. Architecture Review Exercise
Scenario: Multi-region user profile store; W=1, R=1; profile includes email (unique) and avatar URL.
Review prompts:
- Can two regions register same email during partition?
- Is avatar staleness acceptable? Email uniqueness?
- What W/R for email vs avatar in same document?
- Idempotency for profile updates?
- Migration path to stronger consistency for email only?
Expected findings: Unique constraints need coordination; split document or regional authority; eventual alone insufficient for uniqueness without extra protocol.
20. Whiteboard Explanation
90-second version:
"Eventual consistency means if we stop writing and let replication finish, all replicas agree. Until then, reads can be stale and concurrent writes can conflict. It's the AP side of CAP—stay available during partition, reconcile after. Dynamo did this with quorums you tune: low W and R for speed, higher for less staleness. You need version vectors or similar to detect conflicts, read repair and anti-entropy to converge, and application merge policy—LWW is easy but loses data. Kleppmann stresses it's not absence of consistency but a guarantee about the limit. Principal architects pick it when downtime hurts more than temporary wrong reads, and invest in idempotency and conflict handling."
21. Interview Questions
-
Define eventual consistency.
- Signals: Quiescence, convergence, interim divergence allowed.
-
CAP theorem—what is sacrificed in AP?
- Signals: Linearizable consistency during partition; availability retained.
-
How does Dynamo converge?
- Signals: Read repair, anti-entropy, hinted handoff, quorums.
-
What is a sibling?
- Signals: Concurrent versions; vector clock compare.
-
Risks of W=1, R=1?
- Signals: Stale reads, durability loss on node failure.
-
Eventual vs causal consistency?
- Signals: Causal preserves happens-before; eventual does not.
-
Can eventual consistency lose writes?
- Signals: Yes—LWW, partition, no durable quorum.
-
What is read repair?
- Signals: Fix replicas on read when versions differ.
-
PACELC extension?
- Signals: Latency vs consistency without partition.
-
How do CRDTs relate?
- Signals: Stronger convergence semantics for datatypes; still often AP.
-
Design idempotency for eventual consumers.
- Signals: Dedup keys, version checks, at-least-once delivery.
-
Staleness SLO for AP system?
- Signals: Lag metrics, p99 bound, client refresh strategy.
-
When reject eventual consistency?
- Signals: Invariants need immediate global agreement (unique, balance).
-
Hinted handoff purpose?
- Signals: Write availability when replica down; replay later.
22. Interview Follow-Ups
-
Measure convergence time after partition heal?
- Signals: Lag dashboards, chaos experiments, key sampling.
-
Email uniqueness under AP?
- Signals: Central authority, consensus per email, or accept risk.
-
Compare Dynamo quorums to Cassandra consistency levels.
- Signals: Tunable R/W; LOCAL vs GLOBAL scope.
-
Executive wants both CAP C and A?
- Signals: Impossible under partition; scope reduction, mitigation.
-
Migrate AP cart to stronger model?
- Signals: Per-user leader, CRDT, or CP metadata service.
22A. Production Low-Level Design (Interview + Game Day)
Design AP/EL preferences with explicit merge and a CP carve-out. Production LLD and Game Day Standard.
Data model
| Field class | Model | Conflict strategy |
|---|---|---|
| Theme / locale | Eventual | LWW or CRDT merge |
| Marketing flags | Eventual | Version vector + UI resolve |
| Password / 2FA | CP / strong | Single-region or consensus |
Step-by-step flow:
| Step | Guarantee | Client UX |
|---|---|---|
| 1–2 | Local durability | Fast write |
| 3–4 | Eventual visibility | Session guarantee optional |
| 5–6 | Convergence | Deterministic merge |
SLO
Staleness SLO: p99 replication lag < X seconds; conflict rate dashboard.
22B. Game Day Playbooks
| # | Drill | Inject | Detect | Mitigate | Verify |
|---|---|---|---|---|---|
| GD-1 | Replication lag | Pause async channel | Lag SLO burn | Read repair / throttle writes | Convergence after heal |
| GD-2 | Concurrent conflict | Dual-region write same key | Conflict metric | Merge rule fires | Converged value matches spec |
| GD-3 | Security field on EL path | Try weak write on 2FA | Authz deny | Force CP path | Strong path only |
GD-2 — Concurrent update merge
23. Strong Answer Example
Question: "Design a globally available user settings service."
Answer this as a 45-minute greenfield design using the PRACTICE framework. Below is how a strong student sounds aloud—AP/EL for preferences, with explicit merge and a CP carve-out for security-critical fields.

Figure A: PRACTICE map — Problem → Requirements → Assumptions → Capacity → Topology → Invariants → Constraints → Evolution.
Student interview script (PRACTICE)
P — Problem framing
"We're designing a user settings service that must stay available worldwide—theme, locale, notification prefs, etc. Users should update settings near them without waiting on a distant quorum, and keep reading during a regional outage.
That points to eventual consistency: local write ACK, async replicate, converge when healthy. Settings tolerate brief staleness; money and passwords do not.
Non-goals: Spanner for every preference field, or 'Cassandra will sync eventually' without conflict policy."
R — Requirements
| Type | Requirement |
|---|---|
| FR | Get/put user settings document (or field patch); multi-device sync |
| NFR | Global availability under partition; p99 write ACK low (local); lag SLO (e.g. p99 < 5–30s) |
| Consistency | Eventual converge; read-your-writes for the editing user when possible |
| Security carve-out | Password / MFA / billing flags → CP sub-path |
| Ops | Lag alerts; conflict metrics; documented merge rules |
"I'll ask: active-active all regions? Field-level vs whole-doc? I'll assume multi-region active-active, per-
user_iddocument, soft prefs vs hard security split."
A — Assumptions (state aloud)
| Assumption | Why it matters |
|---|---|
| Soft settings can diverge briefly | Enables AP writes |
| Concurrent edits rare but real (two devices) | Need vectors / CRDT / field policy |
| Sticky routing or session affinity available | Helps read-your-writes |
| Dynamo/Cassandra/Cosmos-style store OK | Tunable W/R |
| Wall-clock LWW alone is weak | Prefer versions / CRDTs for critical merges |
"If they insist always-fresh everywhere, I'd push PACELC: that costs EC latency or PC unavailability—wrong default for theme prefs."
C — Capacity (back-of-envelope)
Users → 100M (say)
Settings reads/user/day → high (every session)
Settings writes/user/day → low (few)
Peak write QPS → thousands (bursty, still modest)
Doc size → few KB JSON
Replication lag SLO → p99 < 5–30s; page at breach
Conflict rate → should be tiny; alert if spikes
"This workload is read-heavy, write-light—perfect for local write + async fan-out."
T — Topology (draw this)

Figure B: US/EU/APAC local stores; async replicate; sticky region for read-your-writes; CRDT/field LWW merge; lag SLO.
Pattern choice: Multi-region AP/EL for preference docs; CP microservice for security/billing flags.
| Concern | Approach |
|---|---|
| Write path | Local region ACK; async replicate |
| Read-your-writes | Sticky region / session; or read repair / quorum for that user |
| Concurrent edits | Version vector / per-field version; CRDT for sets/counters |
| Non-critical field conflict | Field-level LWW with version (not raw wall clock alone) |
| Anti-entropy | Gossip / stream / Dynamo-style repair |
| Caching | Short TTL; don't hide conflicts longer than lag SLO |

Figure C: Local ACK → async replicate → sticky read-your-writes → merge concurrent edits → converge.
API sketch:
PUT /users/{id}/settingswithIf-Match/ client version (idempotent upsert).- Persist in local region; return
200+ new version. - Replicate asynchronously; consumers merge by policy.
GETfrom sticky region when possible; else accept staleness within SLO or use quorum read for "important" prefs.
I — Invariants (safety)
"Non-negotiable:
- Convergence: after quiescence, all regions agree on the settings doc (modulo policy).
- No silent lost updates without a defined merge—detect concurrency (vectors).
- Security fields never on the AP path—password/MFA → CP.
- Idempotent PUT—retries don't fork phantom versions carelessly.
- Staleness is bounded by SLO—breach ⇒ alert, not surprise."
C — Constraints (second C)
| Constraint | Design response |
|---|---|
| Two devices edit offline | Field merge / CRDT; show "synced" UX |
| Cross-region read after write | Sticky routing; optional sync read API |
| CDN caching settings | Very short TTL or bypass for authenticated GET |
| Billing language / tax region | Treat as CP or strongly consistent flag |
| Wall-clock LWW | Avoid for multi-writer; use HLC/version |
E — Evolution (phased + prove)
Phased delivery:
| Phase | Deliverable |
|---|---|
| M1 | Single-region settings + versioned PUT |
| M2 | Multi-region async replicate; lag SLI/SLO |
| M3 | Sticky read-your-writes; conflict metrics |
| M4 | Field-level merge policies / CRDTs where needed |
| M5 | Split CP auth settings; chaos partition game day |
Failure modes:
| Failure | Mitigation |
|---|---|
| Partition both sides write | Vector detect + merge policy |
| Long lag | Alert; degrade UX ("settings may take a minute") |
| Cache serves ancient prefs | TTL bound ≤ lag SLO |
| Password on eventual store | Move to CP—non-negotiable |
| LWW clock skew wrong winner | Versions / HLC |
Observability: replication_lag_p99, conflict/merge count, sticky miss rate, CP vs AP traffic split.
Closing line (interview)
"So: globally available settings = AP/EL—local write, async replicate, versioned merge, lag SLO, sticky read-your-writes. I'd use Dynamo/Cassandra-style storage with explicit conflict policy—not hope. Passwords and billing flags stay CP. Eventual consistency is a contract with convergence, not 'no consistency.'"
Scoring signals
| Strong | Weak / red flag |
|---|---|
| AP/EL + lag SLO | "Cassandra syncs eventually" |
| Conflict detection / merge policy | No concurrent-edit story |
| Read-your-writes (sticky) | Ignores own-write visibility |
| CP carve-out for security | Password on eventual store |
| Idempotent versioned PUT | Blind overwrite |
| Anti-entropy / repair | Cache-only "fix" |
Compact outline (if time-boxed to 2 minutes)
"AP multi-region settings doc keyed by user_id. Local ACK, async replicate, lag p99 SLO. Version vectors / field merge; sticky region for read-your-writes. Idempotent PUT. Password/MFA on CP service. Alert on lag and conflicts. Not for balances."
24. Weak Answer Example
Question: "Design a globally available user settings service."
"Use Cassandra with eventual consistency. It'll sync eventually. Add caching for speed."
Why weak / red flags: No W/R tuning, no conflict detection, no field-level policies, no security exception, no staleness SLO; caching can worsen staleness.
25. Hands-On Exercise
Lab: labs/lab-005-eventual-consistency/ — convergence simulator on :8099
cd labs/lab-005-eventual-consistency
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pytest tests/ -v
docker compose -p lab005 -f docker/docker-compose.yml up --build -d
chmod +x scripts/demo_consistency.sh && ./scripts/demo_consistency.sh
| Step | Endpoint | What happens |
|---|---|---|
| 1 | POST /v1/keys/{key} | W=1 write on chosen replica |
| 2 | GET /v1/keys/{key}?replica=r2 | Stale read before async replication |
| 3 | POST /v1/replicate/run | Background anti-entropy push |
| 4 | POST /v1/chaos/partition | Isolate replica during writes |
| 5 | POST /v1/keys/{key}/repair | Read repair converges lagging replica |
Swagger: http://localhost:8099/docs
Engineer guide: how the local stack works
- 3 replicas — async replication with configurable delay; W=1 fast path, R=1 default read.
- Version tokens — each write increments version; reads return replica-local value (may be stale).
- Anti-entropy worker —
POST /v1/replicate/runpushes pending updates to peers. - Partition chaos — isolate a replica; observe divergent reads until heal + repair.
- Read repair — on-demand push of latest version without incrementing write version.
Pairs with Amazon DynamoDB Consistency and Lab 002 vector clocks.
Build-from-scratch exercise (optional)
- Simulate 3 replicas, async replication delay, W=1, R=1.
- Inject concurrent writes during partition; log divergent reads.
- Implement read repair on read; measure time to convergence after heal.
- Add LWW vs vector sibling merge; compare data loss cases.
- Write product-facing doc: what users may see for 60s after edit.
Success criteria: Demonstrate stale read before repair; document one scenario where LWW loses a write.
26. Knowledge Check
- What triggers convergence in theory? (Quiescence—no new writes, repair complete.)
- AP during partition sacrifices what? (Strong/linearizable consistency.)
- Does read repair run on every read in Dynamo? (Design choice—often probabilistic.)
- Sibling detection mechanism? (Vector/version clock concurrent compare.)
- Is W=1 durable? (Not necessarily—depends on failure before replication.)
- PACELC "else" branch? (Latency vs consistency without partition.)
27. Flashcards
| # | Front | Back |
|---|---|---|
| 1 | Eventual consistency | Quiescent replicas converge to same value. |
| 2 | CAP (partition) | Linearizability vs availability—not both. |
| 3 | AP system | Available under partition; typically eventual. |
| 4 | Staleness | Read older than another replica or prior write. |
| 5 | Read repair | Update lagging replicas during read. |
| 6 | Anti-entropy | Background replica reconciliation. |
| 7 | Hinted handoff | Buffer writes for temporarily down replica. |
| 8 | Sibling | Concurrent conflicting versions. |
| 9 | LWW risk | Clock skew → silent data loss. |
| 10 | PACELC | Partition: A/C; else: Latency/Consistency. |
| 11 | Dynamo | N,R,W tunable quorums; vector clocks. |
| 12 | Not guaranteed | Immediate consistency, conflict freedom. |
28. Cheat Sheet
EVENTUAL CONSISTENCY
- Stop writes + repair → replicas agree
- During: stale reads, conflicts OK (by model)
- AP / CAP availability side
CONVERGE VIA
- Async replication
- Read repair (often probabilistic)
- Anti-entropy / gossip
- Hinted handoff
CONFLICTS
- Version vectors → siblings
- LWW (risky), app merge, CRDTs
TUNE
- N, R, W quorums (Dynamo)
- Cassandra CL per query
INTERVIEW
- Not "no consistency"
- vs causal, vs linearizable
- Kleppmann: define merge policy
29. Related Concepts
- CAP Theorem — prerequisite partition tradeoff framing
- Linearizability — stronger alternative (CP)
- Causal Consistency — middle ground preserving happens-before
- Vector Clocks — conflict detection metadata
- Replication — sync vs async paths
- Distributed Databases — Dynamo-family systems
30. References
Primary sources
- Gilbert, S., & Lynch, N. (2002). "Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services." SIGACT News — formal CAP proof using linearizability.
- DeCandia, G., et al. (2007). "Dynamo: Amazon's Highly Available Key-value Store." SOSP — eventual consistency, quorums, vector clocks, read repair.
- Herlihy, M. P., & Wing, J. M. (1990). "Linearizability: A Correctness Condition for Concurrent Objects." ACM TOPLAS — contrast model for strong consistency.
Production and engineering
- Abadi, D. (2012). "Consistency Tradeoffs in Modern Distributed Database Design." IEEE Computer — PACELC formulation.
- Vogels, W. (2009). "Eventually Consistent." — operational perspective (blog; anecdotal, not formal proof).
Textbooks
- Martin Kleppmann, Designing Data-Intensive Applications (O'Reilly) — Chapters 5, 7, 9 on replication, consistency, and conflict resolution.
- Herlihy, M., & Shavit, N. (2020). The Art of Multiprocessor Programming — consistency spectrum context for concurrent objects.
Distinction
| Claim type | Source |
|---|---|
| CAP partition tradeoff | Gilbert & Lynch (2002) |
| Dynamo mechanisms | DeCandia et al. (2007) |
| PACELC | Abadi (2012) |
| Linearizability contrast | Herlihy & Wing (1990) |
| Convergence time in production | Operational measurement—no universal bound |