In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Select: select library is an event-driven model library that is basically supported on both linux and windows platforms, and the definition of interface is basically the same, but the meaning of some parameters is slightly different. The maximum concurrency limit is 1024, which is the earliest event-driven model.
2. Poll: in the basic driver model of Linux, windows does not support this driver model and is an upgraded version of select. It removes the maximum concurrency limit. When compiling nginx, you can use-- with-poll_module and-- without-poll_module to specify whether to compile the select library.
3. Epoll: epoll is one of the highest performance event-driven libraries supported by Nginx servers, and it is recognized as a very excellent event-driven model. It is very different from select and poll. Epoll is the upgraded version of poll, but it is very different from the efficiency of poll. The way epoll handles it is to create a list of events to be processed, then send this list to the kernel and check the table in rotation when returning to determine whether the event has occurred. Epoll supports that the maximum number of event descriptors opened by a process is the maximum number of files that the system can open, and the IO efficiency of the epoll library does not decrease linearly with the increase in the number of descriptors. Because it only operates on the "active" descriptors reported by the kernel.
Select: as stipulated by POSIX, it is currently supported on almost all platforms, and its good cross-platform support is also one of its advantages. In essence, it is to deal with the shortcomings of the next step by setting or checking the data structure of storing fd flag bits. There is a maximum limit on the number of file descriptors that a single process can monitor, which is generally 1024 on Linux. It can be implemented by modifying the macro definition FD_SETSIZE and then recompiling the kernel. However, this will also result in a reduction in efficiency. The default is 1024. To modify this value, the kernel needs to be recompiled. The socket is linearly scanned, that is, the polling method is adopted. The less efficient select adopts the memory copy method to implement the kernel to notify the user space of FD messages, which is a data structure used to store a large number of fd. This makes it expensive for user space and kernel space to copy when passing the structure.
Poll: essentially no different from select, it copies the array passed in by the user to the kernel space, and then queries the device status corresponding to each fd. There is no limit on the maximum number of connections, because a large number of fd arrays stored based on the linked list are copied between the user state and the kernel address space as a whole, regardless of whether such replication is meaningful or not. The characteristic of poll is "horizontal trigger", if fd is reported. If it is not processed, the fd will be reported again at the next poll.
The enhanced versions of select and poll proposed in the Linux 2.6kernel support horizontal trigger LT and edge trigger ET. The biggest feature is edge trigger, which only tells the process which fd has just become required, and will only notify the process to use the "event" readiness notification. Once the fd is ready, the kernel will use a callback mechanism similar to callback to activate the fd. Epoll_wait can receive notification advantages: there is no limit on maximum concurrent connections: the upper limit of FD that can be opened is much greater than 1024 (1 GB of memory can listen for about 100000 ports). Take a look at / proc/sys/fs/file-max, this value is related to the memory size of the system. Efficiency improvement: non-polling will not decrease with the increase in the number of FD. Only active FD calls the callback function, that is, the biggest advantage of epoll is that it only manages "active" connections, but has nothing to do with the total number of connections, and uses mmap (Memory Mapping) to accelerate message delivery with kernel space; that is, epoll uses mmap to reduce replication overhead.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.