worker_connections定义的每个worker进程所能打开的最大并发连接数,但不是max_clients,因为worker_connections定义的是每个worker进程的最大并发连接数,so~max_clients应该是 worker_connections*worker_peocesses。

worker_connections number

Syntax: worker_connections number;
worker_connections 512;
Context: events
Sets the maximum number of simultaneous connections that can be opened by a worker process.

It should be kept in mind that this number includes all connections (e.g. connections with proxied servers, among others), not only connections with clients. Another consideration is that the actual number of simultaneous connections cannot exceed the current limit on the maximum number of open files, which can be changed by worker_rlimit_nofile.

use method

Syntax: use method;
Default: —
Context: events
Specifies the connection processing method to use. There is normally no need to specify it explicitly, because nginx will by default use the most efficient method

@> NGINX在并发处理上之所以能够强于apache,便是因为nginx默认的并发连接处理方式为epoll(异步非阻塞),而apache是select(同步阻塞),如官方文档所说,默认选择的就是最优的没事别改这个

i> NGINX处理新的连接请求从方法

accept_mutex on | off

Syntax: accept_mutex on | off;
accept_mutex off;
Context: events
If accept_mutex is enabled, worker processes will accept new connections by turn. Otherwise, all worker processes will be notified about new connections, and if volume of new connections is low, some of the worker processes may just waste system resources.

There is no need to enable accept_mutex on systems that support the EPOLLEXCLUSIVE flag (1.11.3) or when using reuseport.
Prior to version 1.11.3, the default value was on.

Last modification:January 28th, 2019 at 10:28 pm