Nginx + php fcgi + high load = hang

debianfastcginginxPHP

I've got PHP working in fast-cgi configuration with nginx (0.7.65-2~bpo50+1), PHP 5.2.9, but I find that our busy website hangs when there is high load. The problem is immediately relieved by killing and restarting the php processes. I have 8 php worker processes, and 2 nginx workers.

I understand this is quite a common problem in this configuration, but have not been able to identify an elegant solution. Has anybody any suggestions?

Any help much appreciated! 🙂

Best Answer

I found having less PHP instances, or at most as many PHP instances as nginx instances, improved stability dramatically.

Unfortunately, and it pains me to say this, but after many months of running a high traffic website under this configuration, I found it better to redeploy it on EC2 running Apache + mod_php, which is rock-solid. Because it's on EC2, I can scale the amount of juice required (even if this is more than nginx). So although it may cost more, it substantially reduces the amount of maintenance effort involved in getting it to work.

It's a shame really because I honestly hate apache and love nginx but what can I say?