Nginx does not turn on using multicore CPUs by default, we can make full use of multicore CPUs by adding worker_cpu_affinity configuration parameters. CPU is the task processing, compute the most critical resources, the more CPU cores, the better performance.
Worker_cpu_affinity This parameter should be used together with worker_processes.
First say worker_processes:
Worker_processes indicates the number of processes Nginx will open, according to the official statement, generally open one is enough, open a few more, can reduce the impact of machine IO. Typically 1 to twice times the total CPU core of the current machine. For example, my machine is dual core, then open 4 is enough.
Then say worker_cpu_affinity:
Worker_processes 4; Worker_cpu_affinity 0001 0010 0100 1000;
The above example shows that 4 processes are turned on, and each process is assigned a CPU
The most critical place is not clear, how to represent each CPU?
Well, the 16-core CPU per process assigned to a CPU should be
View CPU status on the server being tested
Top
Then press 1 to see each CPU information
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Nginx CPU Parameters worker_processes and worker_cpu_affinity instructions for use