linux performance server program (ix) --I / O multiplexing

Chapter IX I / O multiplexing

  I / O multiplexing is a thread can simultaneously monitor multiple file descriptors, improve program performance. Although the I / O multiplexing can simultaneously monitor multiple file descriptors, but it itself is blocked, if multiple file descriptors are ready, if no measures are taken it's still a serial work. It can only be handled by multi-process or multi-threaded. I realized the linux / O multiplexing is mainly used to select poll epoll three kinds of mechanisms are multiplexed IO;

  select :

    1) When there are a plurality of I / O streams come in, it does not know which one is ready to perform (read, write) so that polling can select the way to access, so select the time complexity is O (n) so when more and more flow, polling time is getting longer and longer.

    Number 2) select a single process is listening program is limited, that is limited while listening port number size. Monitor the number and size of system memory related Typically, default 32-bit machine monitor size is 1024, the size of the monitor unit 64 is 2048.

    3) The program also needs to maintain a used to store a large amount FD (file descriptor) data structure, so that the user space and kernel space to copy relatively large overhead when the transfer structure. Because it is a whole array of file identifier forth copied from user space and kernel address space.

  poll :

    1) is essentially no difference between the poll and select implementation of the program. That it does not limit the maximum number of connections. Because he is based chain store. Complexity is O (n)

  epoll :

    1) epoll it can be understood as event poll and poll and select are very different. Which specific event will stream I / O event notification to us. So epoll actually are associated with a fd (file descriptor) on event-driven each event. Epoll complexity is O (1) So it's a very high efficiencies.

    2) epoll no maximum concurrent connection limits, be able to monitor about 100,000 ports on the 1G memory.

    3) memory copy, using a mmap () message passing memory mapped file acceleration and kernel space; i.e. using mmap epoll replication overhead reduction.

 

  Reference: https://www.cnblogs.com/lixiaoliuer/p/6735821.html

       https://www.cnblogs.com/aspirant/p/9166944.html

  

   

 

Guess you like

Origin www.cnblogs.com/dump/p/11202715.html