Monday 25 December 2017

'Several instances of node' or 'just using Cluster' for real-time multi-user applications.

I have a multi-user socket.io program where up to 15 people can form a room and chat, draw, and more. Obviously, for a high amount of users I would want to utilize multiple processors (CPU threads), so naturally I should be using node's Cluster.However, I am not sure about it. Right now my program runs on a single processor, and user rooms are basically arrays with which I use socket.io to send a room's information to its residents. If I use Cluster, how exactly will it divide those rooms on the processors? Say I have a 100 rooms (an array of 100 room objects) with 10 users on average for each. Will I just write the code as if it is running on a single processor and let Cluster do the rest? Do I even need to care about this from a performance perspective?What I do know is that if I run several instances of node.js, and redirect new incoming users according to congestion/user's preference, then I will be sure my program will work exactly how it works right now on a single processor. I don't want to use this though since I will need several ports (as far as I know).

Submitted December 25, 2017 at 05:10PM by matazabubu

No comments:

Post a Comment