← Lessons

quiz vs the machine

Platinum1830

System Design

Operational Transformation for Collaboration

Letting concurrent edits to shared text converge by transforming each operation against the ones it missed.

6 min read · advanced · beat Platinum to climb

The concurrent edit problem

Two people edit the same document at once. One inserts a character at position five while the other deletes at position three. Applied naively, the two operations land at the wrong offsets and the documents diverge.

What transformation does

Operational transformation rewrites an incoming operation so it accounts for operations it did not see. If a peer inserted text before your edit position, your position is shifted forward so the intent is preserved.

  • Each edit is a small operation such as insert or delete at a position.
  • When two operations are concurrent, each is transformed against the other.
  • After transformation both sites apply both operations and reach the same document.

Why it is subtle

The transformation function must satisfy a convergence property: applying operations in different orders, with the right transforms, must yield identical results. Getting this correct for every operation pair is famously hard, which is why most systems route edits through a central server to simplify ordering.

Key idea

Operational transformation lets concurrent document edits converge by rewriting each operation against the ones it missed, preserving intent so all sites reach an identical final document.

Check yourself

Answer to earn rating on the learn ladder.

1. What does operational transformation do to an incoming operation?

2. Why do many operational transformation systems route edits through a central server?