I have a Node.js application that uses sockets.io to allow multiple users to edit the same document at the same time (a little like Google Docs).
I want to scale this out horizontally, but I'm stuck trying to figure out how to ensure all the users editing a specific document end up connected to the same Node.js instance.
For example, assume there are 2 documents (doc-A
and doc-B
), and two servers (server-1
and server-2
). Someone connects and starts editing doc-A
on server-1
. Another user connects, also wanting to edit doc-A
. They must be sent to server-1
to ensure the document remains consistent. Finally, a third user connects wanting to edit doc-B
. We could send them to either server as no one is editing that document at the moment.
I'm sure every collaborative editing experience must solve this problem, but I can't figure out how to do it. Can anyone help?
0 Answers