← Lessons

quiz vs the machine

Platinum1820

Concurrency

Operational Transform Basics

How collaborative editors reconcile concurrent edits by transforming operations against each other.

6 min read · advanced · beat Platinum to climb

The collaborative editing problem

Two people edit the same document at once. Each types at a position measured in their own view of the text. When their operations cross on the network, applying them naively corrupts the document because positions shift. Operational transform, or OT, reconciles them.

Transforming operations

OT represents edits as operations, such as insert a character at position five or delete at position three. When a remote operation arrives, the editor transforms it against any concurrent local operations it has not yet seen, adjusting positions so the intent is preserved.

  • If a concurrent insert happened before the position, the incoming position shifts right.
  • If a concurrent delete removed earlier characters, the position shifts left.

The hard part

The transform function must satisfy a convergence property so that all sites reach the same final document regardless of operation order. Getting these functions correct for every pair of operation types is famously tricky, which is why many newer systems choose CRDTs instead. OT usually relies on a central server to order operations, simplifying the cases it must handle.

Key idea

Operational transform adjusts each concurrent edit position against the others so collaborators converge on the same document, often with a central server ordering operations.

Check yourself

Answer to earn rating on the learn ladder.

1. What does operational transform adjust when a remote operation arrives?

2. Why do many newer systems prefer CRDTs over OT?