Epoll & Select & Poll can only handle IO-related operations, epoll each operation must be registered with the time monitoring mechanism and also require process or thread management.
Multi-process/multi-threaded and Epoll compared
Epoll used in a number of links, less processing projects;
Multi-threaded/multi-process with a small number of links, complex business processing.
In QQ, processing login is Epoll implementation, because Epoll can only handle IO-related operations, so epoll will log data back to the process or thread to do subsequent processing, and the SQL query to the database to request data to the database, and high concurrency is resolved at the Epoll end.
Epoll is more than poll. High-speed mode (Edge trigger)
PPC/TPC (Multi-process/multi-threaded)
Small system resources, increase the number of connections, the system overhead, each link has a separate thread/process, real-time, the number of connections is generally hundreds of
Select
Polling is used and the number of connections is between 1024~2048,
Epoll
The default mode (horizontal trigger) is almost the same as poll (except that the Epoll listens for more handles) the number of connections is millions of
Horizontal trigger:
As long as the handle file has an action, then the epoll begins to be occupied. The example in Nainx will accept the data completely.
Edge Trigger:
When the data is accepted, Epoll begins to manage it. The example in Nginx will receive the data that is not received when the second data arrives.
Note: The handle of epoll is increased and the efficiency is decreased. Epoll removed the encapsulation of the PPC/TPC process.
Write a epoll once