【问题标题】:Error upstream timed out. What is wrong with my setup?错误上游超时。我的设置有什么问题?
【发布时间】:2014-09-30 10:19:26
【问题描述】:

我在 2GB ram/2x CPU digitalocean vps 上运行 wordpress 3.9.1,在 debian 7 x64 下使用 nginx 和 php5-fpm 在 tcp/ip 127.0.0.1:9000 上。我遇到大量 504 网关超时。 nginx 日志输出为: 上游超时(110:连接超时)同时连接到上游或 从上游读取响应头时上游超时(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 网关超时时,网站变得无响应。

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

【问题讨论】:

    标签: php wordpress nginx


    【解决方案1】:

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

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

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

    另外,nginx 抱怨上游超时。你有上游的 confs/servers 吗?

    【讨论】:

    • 在更改为 127.0.0.1:9000(来自 unix 套接字)之前,我在 /etc/nginx/conf.d/ 中使用了上游 php5-fpm.conf,它具有:上游 php5-fpm-sock { 服务器 unix:/var/run/php5-fpm.sock; }
    • 你能把那个配置贴出来吗?
    • 我在问题块中添加了上游 conf 文件配置。你能查一下吗?
    • 如果您使用 TCP,则不需要它。只需将其删除。
    • 我刚刚删除了它。谢谢,我将在今天晚些时候发送更新的进展。我还想提一下,我没有使用 varnish 也没有使用 memcache。
    猜你喜欢
    • 2011-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-25
    • 2018-01-09
    相关资源
    最近更新 更多