Write a epoll once

Source: Internet
Author: User
Tags epoll

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.