Symptoms
- The high CPU usage by Nginx can be found in Plesk > Health Monitoring.
- Many Nginx processes as below can be found on the server:
# top -c
19296 nginx 20 0 318720 223848 2212 S 0.3 2.1 0:00.23 nginx: worker process
# top -c
19289 nginx 20 0 318720 223848 2212 S 0.3 2.1 0:00.23 nginx: worker process is shutting down
Cause
Incorrect value of worker_connections
directive.
Resolution
- Log into the server via SSH.
-
Create a backup for Nginx configuration file:
# cp /etc/nginx/nginx.conf{,.orig}
- Get the number of CPU cores (in the example below this value is equal to 4):
# cat /proc/cpuinfo | grep processor | wc -l
4 - Using the vi text editor open the
/etc/nginx/nginx.conf
file and change the value for theworker_connections
equals to 1024 * number of CPU cores:worker_connections 4096;
-
Restart the Nginx service to apply changes:
# service nginx restart