Well, we all have used google docs.

Ever wondered, how it allows multiple people to edit the doc, that too in almost real-time while keeping a consistent state?

Photo by krakenimages on Unsplash

1. This is a common problem with any collaborative platform. There are multiple people — reading/writing and they might be editing at the same location of the document. How do we solve this issue?

2. One simple thing that comes into mind, is to create a lock on the document when a person is editing and prevent others from making any change during this time. This is a common approach, but this results in a loss of performance and the platform is not completely collaborative.

3. Another approach could be to maintain logs of changes made by each person, along with the timestamp, and use those to build the final state of the document. But, what happens if two people perform the operation at the exactly same time?

4. The problem is similar to resolving conflicts during a git merge, but this has to be done automatically without user intervention.

5. Google uses a collaborative protocol to provide near real-time collaboration on google docs. All the clients(our browsers) interact with the Google docs server and perform the required edits.

6. The clients keep a state of 4 things:1) changes present locally but not sent to the server. 2) the most recent version of the doc sent by the server 3) changes sent to the server but not acknowledged by the server 4) the current version of the doc visible to the user.

7. The servers keep a state of 3 things: 1)current state of doc for the server 2) changes it has received but not acknowledged 3) logs of changes applied.

8) Whenever a client receives an edit from the server, it performs changes on the current state of the document by applying operational transform on the changes which the client has not sent to the server and the ones not acknowledged by the server.

To understand in detail:

You can also visualize how the algorithm works here:





Addicted to 007 movies and music of all genres and all generations. A bit of philosophy with a pinch of music and a handful of coding.

Love podcasts or audiobooks? Learn on the go with our new app.

S.O.L.I.D Principles Android

File Handling Using Python GUI

The current state of API access to your Schlage Encode Locks

Step 3 : Building the webpage

Importance Of Python And Reasons For Choosing It

Using XLOOKUP to retrieve data


Post/Put using Jetpack WorkManager

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sukhad Anand

Sukhad Anand

Addicted to 007 movies and music of all genres and all generations. A bit of philosophy with a pinch of music and a handful of coding.

More from Medium

Used dropbox/drive to upload files?

How to identify a great tech organisation before you join

QR Code, Let’s Try to Understand It.

Why you should give Pair Programming a chance