Skip to the content.

⚙️ What is a Conflict?

Definition:

In a distributed system, a conflict occurs when multiple replicas of the same data diverge, usually because concurrent updates happen on different nodes.

Goal:


1️⃣ Last-Write-Wins (LWW)

Concept:

Pros:

Cons:

Example:

Node A Node B
Value: 10 Value: 15
Timestamp: 1000 Timestamp: 1005

Use Cases:


2️⃣ Merges / CRDTs (Conflict-Free Replicated Data Types)

Concept:

Types of Merges:

  1. Set merge → combine elements from both replicas

    • Example: {a, b} + {b, c} → {a, b, c}
  2. Counter merge → sum increments

    • Example: +1 on node A, +2 on node B → total = 3
  3. Custom merges → application-specific logic (e.g., concatenating strings, merging JSON)

Pros:

Cons:

Use Cases:


3️⃣ Manual Conflict Resolution


4️⃣ Operational Transformation (OT)


🔧 Comparison Table

Strategy Automatic? Data Loss Risk Complexity Use Case
LWW ✅ High Low Key-value stores, caches
Merge / CRDT ✅ Low Medium-High Collaborative apps, counters
Manual ❌ None Low Complex domain-specific data
OT ✅ Low High Real-time collaborative editing

🧩 Analogy


✅ Key Takeaways

  1. Conflicts arise in distributed systems due to concurrent updates.
  2. Last-write-wins → simple, may lose data
  3. Merges / CRDTs → preserve all updates, deterministic
  4. Manual resolution → human intervention
  5. Operational Transformation → for real-time collaboration