News for hackers. Stuff that matters.
Re:The WebSocket Handbook by superasn on Tuesday January 11, 2022 @01:04PM (#29895165)
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/

Re:The WebSocket Handbook by jkarneges on Tuesday January 11, 2022 @01:36PM (#29895655)
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.

Re:The WebSocket Handbook by born-jre on Tuesday January 11, 2022 @03:00PM (#29896988)
Re:The WebSocket Handbook by AlexTDiaconu on Tuesday January 11, 2022 @01:37PM (#29895678)
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!

Re:The WebSocket Handbook by hammersmith on Tuesday January 11, 2022 @01:10PM (#29895258)
Have a look at https://m-ld.org/ , its a CRDT implementation that's all Javascript. it could help
Re:The WebSocket Handbook by superasn on Friday January 21, 2022 @09:39AM (#30024044)
Looks very promising. Thanks for sharing!
Re:The WebSocket Handbook by matt_oriordan on Tuesday January 11, 2022 @02:24PM (#29896450)
Yup, and it supports Ably too, see https://js.m-ld.org/#ably-remotes!

Matt, Ably co-founder

Re:The WebSocket Handbook by mathgladiator on Tuesday January 11, 2022 @04:28PM (#29898219)
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.