Sreyan Chakravarty wrote:
Is this really a scalable solution ? In the real world millions of people are online and chatting, so do real servers store the open connections in a collections like structure ?
Claude Moore wrote:
Sreyan Chakravarty wrote:
Is this really a scalable solution ? In the real world millions of people are online and chatting, so do real servers store the open connections in a collections like structure ?
Well, first I would say that in real world chat applications would not rely on a single server instance ! As far as I know, how many sockets you can have opened at the same time on a given machine is not a language matter, is more related to underlying SO capabilities. If I don't remember wrong, on Linux for example sockets and file descriptors are treated in a very similar way, and using ulimit settings is quite easy to raise up maximum number of allowed opened sockets to a fair high number. Of course, this number is not infinite. If you need to track them programmatically, you need of course to use some data structure, and in this case language adopted does matter. Suppose that you have a so large number of connections you cannot keep them all in main memory:you should try to swap them on disk. In java you cannot swap sockets object to disk - sockets are not serializable. In C socket function opens a socket and returns you a socket ID which is a integer, so you could easily serialize a collection of ints. But the real question, IMO, in this case should be: when a similar scenario is realistic ? I guess that with a couple of GB of RAM, a server would be able to keep in memory a number of Socket object by far greater than number of socket that the SO can actually manage without crashing or loosing performance.
Sreyan Chakravarty wrote:
Just out of curiosity tell me how multiple server instances would help us ? So each server instance would store a certain number of opened connections ? Is that how it works ? And thanks for that excellent explanation that why sockets cannot be swapped to disk.
Claude Moore wrote:
Sreyan Chakravarty wrote:
Just out of curiosity tell me how multiple server instances would help us ? So each server instance would store a certain number of opened connections ? Is that how it works ? And thanks for that excellent explanation that why sockets cannot be swapped to disk.
More or less, yes, you may distribute requests load among a given number of services instances - how to achieve this depends mainly upon adopted technology, but basically there is some piece of software which acts as load balancer.
Don't get me started about those stupid light bulbs. |