Nginx details

Nginx is http server software like Apache. The difference between them is that Apache’s processing speed is slow and consumes memory resources, while nginx is the opposite. Functionally, all Apache modules support dynamic and static compilation, while nginx modules are all statically compiled! Apache’s support for fastcgi is not good, and nginx’s support for FastCGI is very good!

The advantages of Nginx

As a web server, handle static files, Index files, the efficiency of automatic indexing is very high. As a proxy server, it can realize a reverse proxy without cache and improve the running speed of the website. As a load balancing server, it can directly support Rails and PHP internally. It adopts the epoll model and can support many Concurrency and low memory consumption

In terms of stability, the use of segmented resource allocation technology, the CPU and memory occupancy rates are very low. Similar to DOS attacks, nginx is basically useless. In terms of high availability, it supports hot deployment and starts quickly. In the case of uninterrupted service, upgrade directly and run 7X24 hours a day

Nginx modules and working principles

< /p>

Nginx Composed of kernel and modules . The module structure is divided into core module, basic module, third-party module

Core module: http module, event module, mail module

< p>

Basic modules: http FastCGI module, http proxy module, http rewrite module

Third-party modules: http upstream request hash module, notice module, http access key module modules are divided into the following three categories in terms of function:

Handlers (processor module): directly process the request, and perform the operation of outputting content and modifying headers information, there is only one Filters (filtering module): Mainly modify the output content of other processor modules, and finally output the case failure summary by nginx

Proxies (proxy module): mainly interact with some back-end services such as FastCGI to achieve proxy and load balancing In terms of working methods:

Single worker process (default): In addition to the main process, there is also a worker process. Multi-worker process: Each process contains multiple threads.

One of the Naginx modules It is compiled into Nginx, so it is a static compilation method! Then compile the module into a so file, and specify whether to load it in the configuration file!

The master process is mainly used to manage the worker process, including the following 4 main functions:

( 1) Receive signals from the outside world.

(2) Send a signal to each worker process.

(3) Monitor the running status of the woker process.

(4) When the woker process exits (under abnormal circumstances), a new woker process will be restarted automatically.

The woker process is mainly used to process network events. The woker processes are equal and independent of each other. They compete equally for requests from the client. A request can only be made in one Processing in the woker process, the number of woker processes is generally set to the number of machine CPU cores.

Nginx is http server software like Apache. The difference between them is that Apache’s processing speed is slow and consumes memory resources, while nginx is the opposite. Functionally, all Apache modules support dynamic and static compilation, while nginx modules are all statically compiled! Apache’s support for fastcgi is not good, and nginx’s support for FastCGI is very good!

The advantages of Nginx

As a web server to process static files, index files, and automatically index The efficiency is very high. As a proxy server, it can realize a reverse proxy without cache and improve the speed of the website. As a load balancing server, it can directly support Rails and PHP internally. It adopts the epoll model, which can support multiple concurrency and occupy low memory.

In terms of stability, it adopts segmented resource allocation technology, CPU and memory occupancy rates are very low. Similar to DOS attacks, it basically has no effect on nginx. In terms of high availability, it supports hot deployment, starts quickly, and can work in uninterrupted service.

Nginx modules and working principle

Nginx Composed of kernel and modules. The module structure is divided into core modules, basic modules, and third-party modules

Core modules: http module, event module, mail module

< p>

Basic modules: http FastCGI module, http proxy module, http rewrite module

Third-party modules: http upstream request hash module, notice module, http access key module modules are divided into the following three categories in terms of function:

Handlers (processor module): directly process the request, and perform output content and modify headers information operations, there is only one Filters (filter module): Mainly modify the output content of other processor modules, and finally output the case failure summary by nginx

Proxies (proxy module): mainly interact with some back-end services such as FastCGI to achieve proxy and load balancing In terms of working methods:

Single worker process (default): In addition to the main process, there is also a worker process. Multiple worker processes: each process contains multiple threads.

One of the Naginx modules It is compiled into Nginx, so it is a static compilation method! Then compile the module into a so file, and specify whether to load it in the configuration file!

Leave a Comment

Your email address will not be published.