Nginx – PHP 100% cpu usage

nginxPHP

One of my php scripts (setup with php-fpm 7.0 with nginx) needs high cpu usage (legitimately) to complete. I would like it to take more time to complete, but leave the cpu available for other requests. Currently the server is not responsive while that script is running.

I could create some delays with PHP sleep(), but is there a more appropriate method for load balancing?

Best Answer

You might be looking for nice command in Linux/UNIX. Basically, what it does is running a command with a modified scheduling priority. PHP sleep() might not help if running task is heavy by itself - without repeating.