Basic reading: Problem C10K
Using threads (or processes) for each connection makes very simple code. The limit on the number of connections is actually the limit on the number of threads that your system can comfortably multitask.
Using asynchronous I / O to place all sockets in one stream is not so simple code (beautifully wrapped libevent and libev2 ), but much more scalable - it is limited by the number of open files your system processes and, for example, on the latest versions of linux, which measure in millions! For this reason, most web servers and other servers use asynchronous I / O.
However, your server is still the end resource that may be exhausted, and there are many unpleasant attacks than just a lack of capacity to handle new connections.
Firewalls and damage control, for example. backups, dmz, etc. are important elements in real internet services.
source share