Operational Transform - The algo behind google docs collaboration feature

Posted on Aug 09, 2014

In a recent hackathon at my workplace, I was creating a text editor with real time collaborative editing feature similar to that in Google Docs. While researching for this functionality, I came to know about the algorithm behind it known as Operational Trasform. According to Wikipedia, OT is invented for consistency maintenance and concurrency control in collaborative editing of plain text documents.



When multiple sites are collaborating on a single text document, Order of events occured at thses sites becomes an important metric. It the the role of Operational Transform algorithm to maintain the order and execute them. OT supports concurrency by the use of consistency models. These models have features such as Causality (Ensuring execution of events in their order), Convergence ( All occured events have been executed at each site) and Intention (Reflecting effects on each site).

Firepad An open source collaborative text editor is designed to add the real time functionality to dynamic websites. It is by deployed on Firebase app platform and provides true collaborative editing, complete with intelligent operational transform-based merging and conflict resolution.

OT is an awesome algorithm for adding some cool functionalities of modern day web applications. For more knowledge, refer to following links and references .