Suppose you have a server written in Node.js that is a glorified chat server. Users join and create rooms and chat. The users and the rooms are created as expected
var client = new Client()
var room = new Room()
etc.
Within this system is a static class called MessageFactory
that generates server-to-client or client-to-client messages based on some arguments. Here is my question:
If 100s or 1000s of clients are connected to this server, and they are constantly generating new messages from a static class, MessageFactory
, is it more efficient for them to all go through this same class, or is it more efficient for each room to have its own non-static MessageFactory
.
Basically, if all users have to route through one static object, does this mean that it is a bottle neck? Would it make a difference if everyone had their own non-static implementation? I'm envisioning it as a set of pipes and if everyone has to go through the same pipe to access something, it would be slow versus if they had their own. But, not being a comp-sci person, I don't know if this is how programs actually work.
via jozenbasin
No comments:
Post a Comment