As the most important service among web services, nginx undoubtedly has the largest and most frequent workload. Therefore, the performance of nginx directly determines the number of web requests, concurrency, and throughput, which directly affects the user's ability to open the website. The direct feeling of users is that 50x errors will occur. For this type of problem, to ensure that there is no problem with the page program, you can generally focus on checking the nginx configuration. Relevant configurations are defined in nginx.conf. The following is an introduction to some of the most commonly used and basic values.
1. The number of worker_processes. This value is officially recommended to be consistent with the number of CPUs. It can also be set to auto.
2.The number of worker_connections, this value is located in the event, as follows:
events{worker_connections8192;multi_accepton;}
Among them, multi_accept means that nginx accepts as many connections as possible after receiving a new connection notification. The default is on. After setting it to on, multiple workers process the connection in a serial manner, that is, only one worker is awakened for each connection, and the others In the dormant state, after setting to off, multiple workers process connections in parallel, that is, one connection will wake up all workers until the connection is allocated, and those that have not obtained a connection will continue to sleep. When your server has a small number of connections, turning on this parameter will reduce the load to a certain extent, but when the server's throughput is large, you can turn this parameter off for efficiency.
Worker_connections indicates how many connections each worker (child process) can create. The default is 1024 and the maximum is 65535. The author filled in 8192 here. This value is related to server performance.