nginx, php-fastcgi and Ubuntu 10.04
Note: this post is outdated. Use at your own risk.
I’ve been using nginx for this blog and other sites for well over a year, beginning with Ubuntu 8.10. I have had to figure out some things, but overall I have been very pleased. I have upgraded the server for each Ubuntu release since then with no real problems. Yesterday I upgraded to 10.04 and thought all was well when I went to bed last night. However, at some time during the night all of my sites began to return 504 Gateway Timeout errors. Hmm.
I did some checking in logs and detective work with top and such and found that my load averages were running between 6 and 8, on a server that has averaged less than 1 for well over a year. After some research, I discovered that the php-fastcgi process was spawning child processes that did not die off when complete. I have no idea why as I did not change any of the nginx, php-fastcgi or other settings. The high load averages dropped to 0 when I stopped the php-fastcgi service.
After some documentation reading and other failed attempts, I finally solved the 504 problem by making one change in my /etc/init.d/php-fastcgi, adjusting PHP_FCGI_CHILDREN=5 to PHP_FCGI_CHILDREN=2.
I would really like to figure out why the child processes were not ending properly before and why they are now and better understand what is going on. I’ve also noticed that the responsiveness of the site seems slower, but that could just be my imagination as I have no measurements to confirm/deny. Anyway, if anyone has any ideas, please comment.
For those interested, here are my php-fastcgi, nginx.conf, and fastcgi_params files. Also, this is a 256M slice at Slicehost.