1. 工作进程的数量
Syntax: | worker_processes |
---|---|
Default: | |
Context: | main |
Defines the number of worker processes.
The optimal value depends on many factors including (but not limited to) the number of CPU cores, the number of hard disk drives that store data, and load pattern. When one is in doubt, setting it to the number of available CPU cores would be a good start (the value “auto
” will try to autodetect it).
The
auto
parameter is supported starting from versions 1.3.8 and 1.2.5.
2. 工作进程的优先级
Syntax: | worker_priority |
---|---|
Default: | |
Context: | main |
Defines the scheduling priority for worker processes like it is done by the nice
command: a negative number
means higher priority. Allowed range normally varies from -20 to 20.
Example:
worker_priority -10;
3. 工作进程与CPU的绑定
Syntax: | worker_cpu_affinity worker_cpu_affinity |
---|---|
Default: | — |
Context: | main |
Binds worker processes to the sets of CPUs. Each CPU set is represented by a bitmask of allowed CPUs. There should be a separate set defined for each of the worker processes. By default, worker processes are not bound to any specific CPUs.
For example,
worker_processes 4; worker_cpu_affinity 0001 0010 0100 1000;
binds each worker process to a separate CPU, while
worker_processes 2; worker_cpu_affinity 0101 1010;
binds the first worker process to CPU0/CPU2, and the second worker process to CPU1/CPU3. The second example is suitable for hyper-threading.
The special value auto
(1.9.10) allows binding worker processes automatically to available CPUs:
worker_processes auto; worker_cpu_affinity auto;
The optional mask parameter can be used to limit the CPUs available for automatic binding:
worker_cpu_affinity auto 01010101;
The directive is only available on FreeBSD and Linux.
Reference: