CAP forces trade-offs between consistency and availability during partitions. This chapter outlines practical consistency models and advanced convergence techniques for high-scale distributed systems.


1. Strong Consistency vs. Eventual Consistency

Feature Strong Consistency Eventual Consistency (AP)
GuaranteeAll readers see the latest write immediately.Readers eventually see the latest write.
MechanismConsensus (Raft, Paxos) or 2PC.Async replication and reconciliation.
Trade-offsLower availability; higher latency.High availability; developer complexity.
Use CasesFinancial ledgers, security credentials, strict integrity.Social feeds, preferences, shopping carts.

A. Weak Consistency Models

  • Read-Your-Writes: A user reads their own latest write.
  • Session Consistency: Reads within a session reflect earlier writes in that session.
  • Monotonic Reads: Once a value is read, no older version is observed later.

2. Managing Data Convergence Strategies

When choosing Availability (AP), conflicting writes occur during partitions. Convergence strategies reconcile conflicts and restore consistent replica state.

A. Compensating Transactions (Sagas)

  • Problem: Transactional integrity across services without a shared DB.
  • Mechanism: On failure at step N, undo steps 1..Nāˆ’1 via compensations.
  • Trade-off: Semantic integrity, not immediate data consistency.

B. Conflict-Free Replicated Data Types (CRDTs)

  • Problem: Highly available apps with concurrent writes on any replica.
  • Mechanism: Mergeable data structures guarantee convergence regardless of delivery order.
  • Types: State-based (merge full state) and Operation-based (merge commutative ops).

C. Last Write Wins (LWW)

  • Problem: Simple conflict resolution in distributed key-value stores.
  • Mechanism: Highest version/timestamp wins.
  • Trade-off: Vulnerable to clock skew; may overwrite newer data.

3. Advanced Synchronization Techniques

A. Vector Clocks

  • Problem: Track causal relationships in eventual consistency.
  • Mechanism: Per-node counters attached to events indicating happened-before or concurrency.
  • Use Case: Causal consistency; avoid LWW pitfalls with inaccurate timestamps.

B. Anti-Entropy

  • Problem: Detect and correct replica divergence.
  • Mechanism: Background sync using Merkle Trees to compare segments efficiently.

Consistency Model Trade-offs

Relative scores (1–5) for Availability, Latency, Developer Complexity, and Conflict Handling across models.