← Lessons

quiz vs the machine

Gold1450

System Design

Operational Transformation Deep Dive

How OT rewrites concurrent operations so every replica converges.

6 min read · core · beat Gold to climb

What OT does

Operational transformation represents edits as operations such as insert at position five or delete three characters at position ten. When two operations are made concurrently, OT transforms one against the other so it still applies correctly to a document that already saw the first.

The core function

The heart of OT is the transform function. Given operations A and B made against the same starting state, it produces A prime and B prime such that applying A then B prime gives the same result as applying B then A prime. This property is called convergence.

Why a server helps

Pure peer to peer OT needs to transform against many histories, which grows complex. Most systems use a central server that assigns a total order to operations and transforms incoming edits against everything it has already committed.

OT is powerful but the transform functions are notoriously hard to get right for rich content, which motivates the CRDT alternative.

Key idea

OT converges by transforming each concurrent operation against the ones already applied so all replicas reach the same state.

Check yourself

Answer to earn rating on the learn ladder.

1. What does the OT transform function guarantee?

2. Why do many OT systems use a central server?

3. What is a known drawback of OT?