We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Consistency Models
Free preview: the first 2 parts of this 9-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Consistency Models
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Open a Google Doc with a colleague. Both type simultaneously. Changes appear on each other screens in real time. No conflicts. No lost keystrokes. This is operational transformation.
The problem: two users concurrently edit the same document. User A inserts "Hello" at position 0. User B inserts "World" at position 0. If you apply these naively, positions are wrong. OT transforms operations against concurrent operations so they produce the correct result regardless of order.
Google acquired the team behind Google Wave (which used OT) and applied the technology to Google Docs. The algorithm is fiendishly complex, every combination of insert, delete, and format must be handled correctly. This complexity is why many newer systems prefer CRDTs, but OT remains the foundation of the most-used collaborative editors.
The core idea: Given two concurrent operations A and B, compute A-prime (A transformed against B) such that applying B then A-prime produces the same result as applying A then B-prime.
Insert/Insert example:
Insert/Delete:
| Operation Pair | Transform Rule |
|---|---|
| Insert/Insert | If positions overlap, break tie by user ID |
| Insert/Delete | Adjust positions based on which came first |
| Delete/Delete | If same position, one becomes no-op |
The number of edge cases explodes with rich text (formatting, tables, images). This complexity is why OT implementations are notoriously buggy.