select and epoll

WBOY
WBOYOriginal
2016-07-29 08:55:323750browse

Select and epoll are both solutions to the multi-channel I/O mechanism. Select is in the POSIX standard, while epoll is unique to Linux.
The biggest advantage of epoll is that it will not reduce efficiency as the number of FDs increases. Polling is used in select. The data structure is similar to an array data structure, while epoll maintains a queue. You can directly check whether the queue is empty. That's it.
nginx uses epoll to achieve I/O multiplexing and support high concurrency. Currently, nginx is becoming more and more popular in high concurrency scenarios.
One disadvantage of select is that there is a maximum limit on the number of file descriptors that a single process can monitor
epoll:
(1) The efficiency of IO will not decrease as the number of monitored fds increases. Epoll is different from the polling method of select and poll, but is implemented through the callback function defined by each fd. Only ready fd will execute the callback function;
(2) Support level triggering and edge triggering (only tell the process which file descriptors have just become ready, it only tells it once, if we do not take action, then it will not tell again, this method is called edge triggering ) two methods, theoretically the performance of edge triggering is higher, but the code implementation is quite complicated.
(3) Has a good readiness event notification mechanism
select:
(1) The number of fds that a single process can monitor is limited. On a 32-bit machine, the maximum number of fds it can manage is 1024;
(2) The socket is scanned linearly. When the number of socket file descriptors increases, a lot of time is wasted.

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces select and epoll, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn