There is a worker_processes configuration item in the nginx.conf configuration file, which is configured by default:
Worker_processes 1
The number of worker processes directly affects performance.
Each worker process is a single-threaded process that invokes each module to implement a variety of functions, and if the modules confirm that there are no blocking calls, how many worker processes are configured for the number of CPU cores, and if there is a possibility of blocking calls, A little more worker processes are required.
For example:
If the business needs to read a lot of static files on the disk, and the memory on the server is small enough that most requests to access the static file must read the disk rather than the in-memory disk cache, the disk I/O call may block the worker process for a few moments, leading to a degradation in overall service performance.
Multi-worker processes can take full advantage of multi-core system architectures, but if the number of worker processes is greater than the number of CPU cores, it increases the consumption of inter-process switching (Linux is a preemptive kernel). In general, the user configures a worker process that is equal to the number of cores and uses the worker_cpu_affinity configuration to bind the CPU core.