One day a site return 500 status with Nginx+php5-fpm+Wordpress structure.
I checked Nginx error log. I found following error.
..... [error] 846#0: *1650149 upstream timed out (110: Connection timed out) while reading response header from upstream .....
I could fix the problem with php5-fpm setting.
This article is a memo for it.
Linux www3241up 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
1. Check process situation with top or htop command.
2. Change setting about php5-fpm.
$ sudo vim /etc/php5/fpm/pool.d/www.conf ; The number of child processes to be created when pm is set to 'static' and the ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. ; This value sets the limit on the number of simultaneous requests that will be ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP ; CGI. The below defaults are based on a server without much resources. Don't ; forget to tweak pm.* to fit your needs. ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: This value is mandatory. pm.max_children = 5 ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 pm.start_servers = 1 ; The desired minimum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' pm.min_spare_servers = 1 ; The desired maximum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' pm.max_spare_servers = 2
Set low value.
3. Reboot php5-fpm.
$ sudo /etc/init.d/php5-fpm restart
I could solve the problem with this way.