OverviewOne day a site return 500 status with Nginx+php5-fpm+Wordpress structure.
I checked Nginx error log. I found following error.
I could fix the problem with php5-fpm setting...... [error] 846#0: *1650149 upstream timed out (110: Connection timed out) while reading response header from upstream .....
This article is a memo for it.
OSLinux 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.
There are many mysql process.
Looks this is cause.
2. Change setting about php5-fpm.
Set low value.$ 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
3. Reboot php5-fpm.
I could solve the problem with this way.$ sudo /etc/init.d/php5-fpm restart