C10K问题
维基百科描述
The C10k problem is the problem of optimising network sockets to handle a large number of clients at the same time. The name C10k is a numeronym for concurrently handling ten thousand connections. Note that concurrent connections are not the same as requests per second, though they are similar: handling many requests per second requires high throughput (processing them quickly), while high number of concurrent connections requires efficient scheduling of connections. In other words, handling many requests per second is concerned with the speed of handling requests, whereas a system capable of handling a high number of concurrent connections does not necessarily have to be a fast system, only one where each request will deterministically return a response within a (not necessarily fixed) finite amount of time.
The problem of socket server optimisation has been studied because a number of factors must be considered to allow a web server to support many clients. This can involve a combination of operating system constraints and web server software limitations. According to the scope of services to be made available and the capabilities of the operating system as well as hardware considerations such as multi-processing capabilities, a multi-threading model or a single threading model can be preferred. Concurrently with this aspect, which involves considerations regarding memory management (usually operating system related), strategies implied relate to the very diverse aspects of the I/O management.
简单概括
Web2.0时代,由于互联网用户的快速增长,以及应用程序的日趋复杂。最初的服务器都是基于进程/线程模型的,新到来一个TCP连接,就需要分配1个进程或线程。一台机器的资源有限,无法创建很多进程。C10K就要创建1万个进程,操作系统会出现效率低下或崩溃的情况。
问题解决
FreeBSD推出了kqueue
Linux推出了epoll
Windows推出了IOCP
参考文档
- http://rango.swoole.com/archives/381
- http://www.52im.net/thread-566-1-1.html
- http://www.52im.net/thread-578-1-1.html
- https://segmentfault.com/a/1190000007240744