Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement room instancing in socketio-server.js #458

Merged
merged 1 commit into from Mar 22, 2024

Conversation

vincentfretin
Copy link
Member

@vincentfretin vincentfretin commented Mar 20, 2024

Use case: experience with 3000 users, using room instancing by batch of 50 users, no audio, no video, only websocket. We are interested only in avatar movements.

For 50 in a room, you probably want to reduce the update rate to 1 per second instead of 15 by setting NAF.options.updateRate = 1 (doc)

If you test it inside the networked-aframe repo, be sure to use npm run dev-socketio and setting networked-scene="adapter:socketio" in the basic.html or basic-chat.html examples.

Be aware there are pending issues with the socketio adapter:

That's a quick implementation I tested only with maxOccupantsInRoom = 3 instead of 50.
I didn't test the load. Someone has to create a script to test 3000 connections, creating the websocket, sending avatar positions every second, do that for a random duration about 30 seconds to 3 min for each connection and close the websocket connection to see how the node process supports the load.

If someone wants to go further, some things to be tested for cpu/memory/latency:

  • Use a more performance framework, replace express by fastify (nodejs only) or hono (on deno or bun), or h3 (on node or deno or bun)
  • Replace socketio by a more efficient websocket implementation (ws on nodejs?), modify the socketio adapter to use WebSocket directly instead of socketio.
  • Or rewrite the server part entirely in golang or rust/tokio or elixir/phoenix

@vincentfretin vincentfretin merged commit 1d0977d into master Mar 22, 2024
1 check passed
@vincentfretin vincentfretin deleted the room-instancing branch March 22, 2024 13:23
@Utopiah
Copy link
Contributor

Utopiah commented Apr 1, 2024

I'd be curious about metrics here, i.e how many users (10, 100, 1000...) managed on which hardware (RPi Zero, RPi5, i9...) and what is the bottleneck.

@vincentfretin
Copy link
Member Author

If you need perf, I'll probably rewriting server/socketio-server.js with
https://github.com/uNetworking/uWebSockets.js
You can still use socketio lib on the client side I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants