Nginx function module and process management

Source: Internet
Author: User
1. Functions

1.1.Function Description

Use reverse proxy for cache acceleration, simple load balancing and fault tolerance;

Use the cache mechanism to accelerate access to remote FastCGI servers;

Modular structure;

Basic HTTP Functions;

Email proxy server function;

Scalable Architecture: non-blocking, time-driven, multiple workers of one master, highly modular;

The main roles are reverse proxy and CDN cache service.

1.2.Basic module

Kernel module, event driver module, mail module, and service module

Example of related configuration parameters:

Kernel module parameter env \ error_log \ master_process \ User \ worker_cpu_affinity \ worker_processes;

Event module parameter worker_connections \ use;

The maximum number of client connections can be calculated using the work_connections and worker_processes commands:

Max_clients = work_connections * worker_processes;

In the reverse proxy environment, the maximum number of customer connections is changed:

Max_clients = worker_processes * worker_connection/4

The reason is that by default, the next browser will open two connections to the server. nginx uses the file descriptor from the same pool to connect to the upstream server.

HTTP module parameter AIO \ alias \ directio \ error_page \ Listen \ Server \ location \ Root \ SERVER_NAME \ types

 

2. Process Management

2.1.MasterProcess andWorkerProcess

Indicates the master process and worker process, respectively,

The main process processes the following signals: Term \ int \ user1 \ user2 \ Hup \ winch \ quit;

Workprocess: Term \ int \ user1

 

2.2.WorkerQuantity settings

The number of settings can be the same as the number of CPU cores. It is best to reduce one because the Linux system uses the CPU

2.3.ForNginxPairLinuxSystem Optimization

Shut down services not required by the system;

Optimized disk write operations to reduce disk write operations during nginx access;

Optimize resource restrictions, such as setting the number of files that can be opened and the number of processes, and use ulimint-N and ulimit-U;

Optimize kernel TCP options

2.4.OptimizationNginxServer

Disable access logs;

Use epoll

Server Configuration Optimization: for example

Worker_connection 65535

Keepalive_timeout 60

Client_header_buffer_size 8 K

Worker_rlimit_nofile 65535.

 

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.