Skip to the content.

Operational Transformation (OT) and CRDTs, which are key techniques for real-time collaborative systems.


⚙️ What Are They?

Both OT and CRDTs are methods to handle concurrent edits in distributed collaborative applications (like Google Docs, collaborative coding, or Figma), ensuring eventual consistency.


1️⃣ Operational Transformation (OT)

Definition:

OT transforms operations from multiple users so that all replicas converge to the same state, even if edits happen concurrently.

How it Works:

  1. Each user’s operation is sent to the server.
  2. If two operations conflict (e.g., inserting text at the same position), the server transforms one operation relative to the other to preserve intent.
  3. Transformed operations are broadcast to other clients.
  4. All clients apply operations in the same order, achieving consistency.

Example:

Pros:

Cons:


2️⃣ CRDTs (Conflict-free Replicated Data Types)

Definition:

CRDTs are data structures designed for concurrent updates that can merge automatically without conflicts, guaranteeing eventual consistency.

How it Works:

  1. Each client can update its local replica independently.
  2. Updates are propagated asynchronously to other replicas.
  3. A merge function ensures that all replicas converge without coordination.

Types of CRDTs:

Type Example Use Case
Grow-Only Counter Increment-only counter Likes, votes
PN-Counter Positive/Negative counter Accounting
G-Set Add-only set Collaborative lists
OR-Set Add/remove set Shared task lists
RGA / Sequence CRDT Ordered list of elements Collaborative text editing

Pros:

Cons:


🔄 OT vs CRDTs Comparison

Feature OT CRDT
Architecture Usually client-server Can be peer-to-peer
Conflict Handling Transform operations Merge replicas deterministically
Central Authority Required Optional
Complexity Medium-High High (complex data types)
Use Case Real-time collaborative editing Collaborative apps, distributed databases

🧩 Analogy


✅ Key Takeaways

  1. Both OT and CRDTs handle concurrent edits and ensure eventual consistency.
  2. OT: Centralized, transforms operations, preserves user intent.
  3. CRDTs: Decentralized, merges automatically, no coordination needed.
  4. Use OT for real-time text editors like Google Docs.
  5. Use CRDTs for decentralized apps, offline-first apps, or distributed databases.