Nginx Learning Note (vi) Improved 9 times-fold increase in thread pool performance

Source: Internet
Author: User

Original address: https://www.cnblogs.com/shitoufengkuang/p/4910333.html

First, preface

1, NIGNX version: 1.7.11 or more

2, Nginx uses an asynchronous, event-driven method to handle the connection. This approach eliminates the need to create additional dedicated processes or threads for each request, like a server with a traditional architecture, but instead processes multiple connections and requests in a worker process.

3, Nginx working in the non-blocking socket mode, and the use of epoll and kqueue such an effective method.

4, Nginx can be very good to handle the millions scale of concurrent requests.

5, blocking operation can destroy Nginx performance, we must at all costs to avoid the use of blocking.

6, even in the current official Nginx code, still unable to avoid the use of blocking in all scenarios, the thread pool mechanism implemented in NGINX1.7.11 solves this problem

Second, the question

1. Normally, Nginx is an event handler, a controller that receives all the connection events from the kernel and then sends instructions to the operating system.

2. The so-called "blocking operation" means any operation that causes the event processing cycle to stop significantly for a period of time

3, operation can become blocking operation for various reasons

Third, thread pool

1, to Nginx, the thread pool is the function of the distribution service . It consists of a task queue and a set of threads that handle this queue.

2 . When a worker process needs to perform a potentially long operation, the worker process does not perform this operation on its own, but instead puts the task into the thread pool queue, and any idle thread can fetch and perform this task from the queue.

3, the disk reading speed can not be faster than the disk to produce data.

4. The "read from disk" operation is typically the most common example of blocking operations, but in practice, the thread pool implemented in Nginx can be used to handle any tasks that do not fit in the main loop.

5. The two basic operations performed in a thread pool are read () system calls in most operating systems and Sendfile () in Linux.

Nginx Learning Note (vi) Improved 9 times-fold increase in thread pool performance

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.