Hacker News new | ask | show | jobs
by superasn 1622 days ago
Hi! I want to create a web app like Google docs where multiple users can collaborate in real time to edit the document together (using a special link like gdocs generate). I want to save the docs in a MySQL db (no firebase)

My questions are:

1) Since multiple people are working together how does one manage conflicts, i.e. 2 people sending different edits simultaneously.

2) If one clients gets disconnected (4g) and then reconnects later how does it sync the changes it made during it was offline?

I recently watched this RAFT presentation (1) and I think I would need to use something like this?

What other alternatives are viable?

Also can I make it happen using just PHP, Javascript and MySQL?

Thanks

(1) http://thesecretlivesofdata.com/raft/

5 comments

I made a document editing demo here: https://github.com/fanout/editor

It uses operational transformations ("OT") to manage conflicts, and it saves the data in MySQL. Technically any Django DB backend will work for storage, but the public demo instance uses MySQL.

One of the reasons I made this thing was to show that realtime apps don't need to require heavy frameworks or unusual databases. And it loads super fast.

I don't think you need Raft if you have a central database storing the document. You could also consider using CRDTs instead of OT, which may be more powerful but also more challenging to develop.

Big question! It deserves its own blog post haha.

CRDTs can be the answer. We actually wrote about them recently (https://ably.com/blog/crdts-distributed-data-consistency-cha...), and there is more coming soon as our Chief Of Scientist and his team are researching CRDTs and building demos!

Have a look at https://m-ld.org/ , its a CRDT implementation that's all Javascript. it could help
Looks very promising. Thanks for sharing!
Yup, and it supports Ably too, see https://js.m-ld.org/#ably-remotes!

Matt, Ably co-founder

CRDT solve a part of your problem, and an important consideration is whether or not you want off-line editing. If you don't need off-line editing, then a WebSocket can do it.

I'm actually using my project to build a collaborative IDE (designer like Figma): http://www.adama-lang.org/

I'm going to be launching it as a SaaS soon so people can spin up a new back-end without managing an infrastructure.