I'm building a very basic 3D multiplayer game using Three.js and Socket.io where all the player does is move in an environment.

Considering there will be ~ 100 players in a single room and all data that is required to be transmitted is their positions. Which of the following two patterns should be used :

  1. Immediately echoing the player's position to other players in the room when a socket event is received :

Server side :

        socket.on("move", (singlePlayerPos) => {
           socket.to(socket.room).emit("player update", singlePlayerPos);

Client side: receiving the event and updating the players position stored in an array/map. Note : client currently emits the position update event on every frame.

  1. Storing the positions on server side and transmitting them on a 'tick rate' basis say every 16 ms
        setInterval(function () {
            io.to(socket.room).emit("positions", allPlayersPositions);
        }, 16);

I'm currently using approach #1 and have concerns whether it'll lead to too many messages for client to handle as the position event is emitted during every requestAnimationFrames() cycle.

The issue I have with approach #2 is that my servers are horizontally scaled and using L4 load balancing (there's no sticky session). The sockets are scaled using Redis adapter (pub/sub) so I can't really store player's positions in memory (RAM) as player belonging to a single room can join different servers. If I'll have to store all positions they'll have to be stored in Redis which i'm concerned would impact performance (latency). Additionally the client is pretty light weight on the "game logic" part but have many other traditional web elements (such as modals, buttons etc.) on the business logic part ... so don't really intend to introduce complexity such as interpolations and predictions (its okay if some players lag/skip at full load).

I'm a beginner when it comes to game development and would appreciate any suggestions and/or criticism.


1 Answer 1


You probably already do this but, in case you don't, one modification that I suggest for both cases is to place a threshold on the position changes so that you are not constantly streaming them (every frame).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .