How does Google Docs sync in Google Drive work?

1

So I could not find this information, but I'm curious to know how real-time syncing of text documents in Google Drive works.

The point is that two people can edit the file at the same time, with the changes appearing for the two virtually instantaneously.

I really want to know how this works to see where I can implement something like that, I accept links with the explanation about it too.

I want to know, how does this synchronization work, in which both can see at the same time what is changed? What language do they use to do this? What bank do they use? What black magic is this?

    
asked by anonymous 04.05.2015 / 15:04

1 answer

1

The theory is not complicated: take what has been modified, send it to the other person with the file open, and update the version of it. Nothing special in between, just Javascript, websocket . Probably no database has (or at least can do without). There is no black magic, let alone something special.

In fact, the implementation of this feature is quite straightforward, being latency (minimized with websocket), connection problems and conflicts the biggest enemies.

The trickiest part is to link one person's changes to another's when they change the same place or property. In this case, I believe it highlights conflicting information and lets the user resolve.

This conflict behavior is different from that of the version controls (git, svn, hg), which first try to resolve the conflict (using 3-way merge, for example) and only if it is not possible, asks the user solve in hand.

    
04.05.2015 / 19:03