If you are not familiar with network programming, it is recommended to learn Linux's network programming section Signal model (or Windows network programming Complete port model). ACE is a nice package, encapsulated these models, but there is no better theoretical basis, and it is not possible to design high performance web servers.
Several models of web servers can be referenced
C10k introduction. Of course, if in Linux, the best model is naturally EPOLL (Effective Poll?). At present, a server supports 10K customer access, basically more troublesome, 64-bit CPUs may be a better solution. 2 1000M NIC, 10K client, the bandwidth of each client is 2000/10000 = 200K, which is theoretical value, barely feasible.
Consider a pure thread model. 10K clients, 10K threads. Considering the user space of each process, then the space of each thread is 3000M / 10K = 300K, which can only be said to be very boring (C runtime each thread requires approximately 2-3K space). However, a large number of thread scheduling will slow down system efficiency.
Consider the model of multiple processes, and each process creates multiple threads. In fact, it is not very different from pure thread model, but the user space of each thread is not too large. The huge performance loss caused by a large number of thread scheduling makes the entire system efficiency and its low. Of course, this model is not an all right, and this model is very suitable for situations where the number of clients is not much, such as an FTP server.
Then there is the remaining EPOLL model. To use the EPOLL model, you must first have Linux2.6 kernel. It is recommended to install Fedora Core2. People who know the SELECT model know that SELECT can only support 64 sockets each handle, which can be learned by reading Linux Select.h. The Poll model is a model triggered with no 64 sockets. EPOLL is a transformation of the Poll model, allowing a POLL handle to support multiple Socket handles at the same time, the benefit is to put a large number of POLL handles in the kernel, greatly reduces the copy of the data from kernel to the user state. The number of times, thereby increasing efficiency. Read Linux's source code can be seen that the internal use of HashMap is in a HashMap. So fundamentally, the Epoll model is a better Poll model (I have always understood Effective Poll).
Observing Linux source code can be seen, every time you create a Socket handle, there will be a File object being created. For C10K, it means that 10K file handles are created. The number of file handles that can be created on the Linux system is limited, and you can read the Struct Files structure of the Linux source code, 1024. Fortunately, the Linux system provides an extension method. The most simple practice is to use a command called ULIMIT, but this command must be done every time the process is started. Another method is to modify the source code and recompile the kernel. This method is more practical, one is eternal.