上游超时错误.我的设置有什么问题?


Error upstream timed out. What is wrong with my setup?

我在debian 7 x64下运行wordpress 3.9.1在2GB ram/2x CPU的digitalocean vps上运行nginx和php5-fpm。我遇到了大量的504网关超时。Nginx日志输出如下:upstream timed out(110:连接超时),连接到upstream或从upstream

读取响应头时,upstream超时(110:连接超时)
www.conf:
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 25
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 8
pm.max_requests = 200
listen_backlog = 65536
request_terminate_timeout = 30
php.ini:
max_execution_time = 30
nginx.conf:
worker_processes 2;
worker_connections 1024;
client_max_body_size 10M;
fastcgi_read_timeout 30s;
client_header_timeout 30s;
client_body_timeout 30s;
fastcgi_send_timeout 30s;    
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
keepalive_timeout 65;
gzip on;
The recommended settings of DO for the sysctl.conf are:    
# Digital Ocean Recommended Settings:
net.core.wmem_max=12582912
net.core.rmem_max=12582912
net.ipv4.tcp_rmem= 10240 87380 12582912
net.ipv4.tcp_wmem= 10240 87380 12582912
the following was removed completely:
php5-fpm.conf (/etc/nginx/conf.d/):
upstream php5-fpm-sock { 
server unix:/var/run/php5-fpm.sock; 
}

我也试过禁用我的插件,但没有运气。当wordpress仪表板显示"连接丢失"消息时,站点变得无响应,最终504网关超时。

有人有类似的经历吗?任何建议都将不胜感激。谢谢。

Nginx worker_processes应该直接与CPU线程相关;因为你有一个2核CPU,那么你应该有2个worker_processes线程。

接下来,尝试将php-fpm服务器的CPU线程数增加到x4个。比如:

pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 8

同时,nginx正在抱怨上游超时。