Home  >  Article  >  Operation and Maintenance  >  How nginx achieves high performance

How nginx achieves high performance

王林
王林forward
2020-06-08 17:31:503699browse

How nginx achieves high performance

How does nginx achieve high performance?

1. Event-driven model

The event-driven model based on asynchronous and non-blocking can be said to be the key factor for Nginx to achieve high concurrency and high performance. . This is similar to Netty. The bottom layer uses BSD kqueue, Linux epoll and Solaris event ports.

2. Multi-process mechanism

There are two advantages of using multi-process:

(1) No resources are shared between processes, no need Locking reduces the impact of using locks on performance, while reducing programming complexity and development costs.

(2) Use independent processes so that the processes will not affect each other. If one process exits abnormally, other processes will work normally, and the master process will quickly start a new worker process to ensure service No interruptions, minimizing risk.

3. Memory pool

In order to avoid memory fragmentation, reduce the number of memory requests from the operating system, and reduce the development complexity of each module, Nginx has designed a simple The main function of the memory pool is to integrate multiple operations of requesting memory from the system into one operation, which greatly reduces the consumption of CPU resources and reduces memory fragmentation.

4. Modular design

Highly modular design is the architectural foundation of Nginx. Openresty introduces third-party modules such as lua on Nginx, making expansion more convenient.

How nginx achieves high performance

Recommended tutorial: nginx usage tutorial

The above is the detailed content of How nginx achieves high performance. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete