How does a server application handle a large number of simultaneous connections from clients?
With a full-strength server, connection sockets aren’t declared as class variables. The server instead uses some sort of dynamic allocation of sockets in an array or link list to create sockets for the clients as the connection requests come in. Another approach often taken by servers is to spin off a separate thread for each connection request. This allows the application to have a single socket connection per thread, making it much easier to keep track of the sockets. In any case, server applications don’t normally have a single connection socket variable. Keep in mind, however, that if too many threads are running, the number of context switches will degrade server performance significantly, so the separate thread per connection may not be an appropriate approach for a heavy-load server application.
Related Questions
- How many licenses do I need for a web-based application that runs on one internet server but can be accessed by many clients?
- How many different OS, application server and DB configurations have you tested with medium to large configurations?
- How many simultaneous clients can a Character Server service?