0

I have been assigned a new website to work on and I have recently moved it to a new server operating at CentOS 7 which is using nginx to host my website made with zend framework.

However, very frequently (10-20 times a day) the cpu usage of the server becomes 100% and the website crashes (504 gateway timeout). The site only works again when I restart the server.

Therefore I have two questions:

How can I restart the server (or nginx, im not sure in this case) when the CPU is fully used?

Or even better is how can identify which file is the source of this issue?

user3186034
  • 45
  • 1
  • 10
  • Depending on the website, it could be mysql hanging? What I've done in the past is use a monitoring tool via ssh, like `glances` or `htop`, which track system stats. I know `glances` does throw up warnings based on High CPU usage, which allowed me to track it down. – Darren Nov 17 '16 at 07:19
  • Did you check your **worker_processes** and your **worker_connections** in the **nginx.conf** If the CPU and amount of memory changed when you switched servers it might be set to high. And in if you are using php-fpm check the pool conf settings for **pm**, **pm.max_children**, **pm.start_servers**, **pm.min_spare_servers**, **pm.max_spare_servers** if they are not set to high. – DenLanden Nov 17 '16 at 13:05
  • I still get the timeout after a few hours even when I changed the values for these variables into the following: worker_connections 512, pm = dynamic,pm.max_children = 4,pm.process_idle_timeout = 10s,pm.start_servers = 2,pm.min_spare_servers = 2,pm.max_spare_servers = 4 – user3186034 Nov 28 '16 at 11:49

0 Answers0