nginx 報錯 upstream timed out (110: Connection timed out)解決方案
error.log報錯如下:
2013/05/18 21:21:36 [error] 11618#0: *324911 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 42.62.37.56, server: localhost, request: "GET /code-snippet/2747/HTML5-Canvas-usage HTTP/1.0", upstream: "fastcgi://127.0.0.1:9002", host: "outofmemory.cn", referrer: "http://outofmemory.cn/code-snippet/tagged/canvas"
報這個錯誤之后,整個服務器就不響應了,但是nginx后面的webpy程序沒有任何錯誤,后端的數據庫也很正常,從網上查了很多資料,都是說要修改proxy_read_timeout,proxy_send_timeout和proxy_buffer幾個相關設置的值。
如下配置,要放在server或者http配置節之內
large_client_header_buffers 4 16k; client_max_body_size 30m; client_body_buffer_size 128k; #proxy_connect_timeout 300; #proxy_read_timeout 300; #proxy_send_timeout 300; #proxy_buffer_size 64k; #proxy_buffers 4 32k; #proxy_busy_buffers_size 64k; #proxy_temp_file_write_size 64k; fastcgi_connect_timeout 300; fastcgi_read_timeout 300; fastcgi_send_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 32k; fastcgi_busy_buffers_size 64k; fastcgi_temp_file_write_size 64k;
你可以看到上面是proxy_和fastcgi_兩種配置,就是說如果你的nginx后面是proxy,就設置proxy相關的配置,如果是fastcgi就設置fastcgi相關的配置。
現在暫時服務器沒報錯了,坐等下一次報錯
續:現在只看到
[warn] 12483#0: *1472 a client request body is buffered to a temporary file /www/wdlinux/nginx-1.0.12/client_body_temp/0000000001, client: 119.188.35.16, server: www.shejiqun.com, request: "POST /Designer-saveLoad-tuku-1.html HTTP/1.1", host: "www.shejiqun.com"
續:服務器經常php解析卡死
查看error.log文件,顯示很多超時
判斷是進程數不夠
增加nginx進程數:
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
另外,查看了一下php-fpm日志,發現
fpm_children_bury() fpm_children_make()錯誤
修改php-fpm.conf的配置,將max_requests和max_children調整為合適的值。
<value name="max_requests">102400</value>
<value name="max_children">100</value>
<value name="max_children">100</value>
另外,增加系統打開文件最大個數配置
在/etc/security/limits.conf最后增加如下兩行記錄
* soft nofile 65535
* hard nofile 65535
待續,看問題是否得到解決
