You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a whiteboard that updates cursors and drawings in realtime, (as in 60fps), that should support 100s of "whiteboards" with 100s of clients at the same time. (demo at https://draw.cafe )
Since this amounts to lots of websocket messages/s, i'm trying to be efficient as possible:
Let the javascript client do most of the work
Use zero-copy flatbuffers to send messages to multiple clients.
Bundle multiple events into a single websocket message.
Currently i'm using threading to support multiple CPU cores, and a separate IO and update thread. However i think the mutexes/atomics are generating too much overhead and are making things too complex.
So singlethreaded-async-everything should be much better for per-core efficiency and reduced complexity. (As has Alex advised in his documentation.)
Would it be possible to move a websocket to a different thread? This way i can have multiple independent threads, and move a client to the correct thread. (e.g. the thread that has the shared session in which a whiteboard exists)
So basically:
Client connects websocket and is assigned to a random thread. (this is how uwebsockets operates when using multiple threads)
Client creates a new shared session. (a "drawing")
Second client connects and is assigned to a different random thread.
Client wants to join shared session, but cant since its in a different thread.
Client socket is moved to the correct thread and can join the session.
(Off course step 4 and 5 would need some locking but since this occurs one time, the overhead doesn't matter.)
Is step 5 possible somehow?
Different ideas to solve this are welcome off course.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm building a whiteboard that updates cursors and drawings in realtime, (as in 60fps), that should support 100s of "whiteboards" with 100s of clients at the same time. (demo at https://draw.cafe )
Since this amounts to lots of websocket messages/s, i'm trying to be efficient as possible:
Currently i'm using threading to support multiple CPU cores, and a separate IO and update thread. However i think the mutexes/atomics are generating too much overhead and are making things too complex.
So singlethreaded-async-everything should be much better for per-core efficiency and reduced complexity. (As has Alex advised in his documentation.)
Would it be possible to move a websocket to a different thread? This way i can have multiple independent threads, and move a client to the correct thread. (e.g. the thread that has the shared session in which a whiteboard exists)
So basically:
(Off course step 4 and 5 would need some locking but since this occurs one time, the overhead doesn't matter.)
Is step 5 possible somehow?
Different ideas to solve this are welcome off course.
Edwin
Beta Was this translation helpful? Give feedback.
All reactions