【问题标题】:110 Connection timed out - using play 2.1.3 and nginx110 连接超时 - 使用 play 2.1.3 和 nginx
【发布时间】:2013-08-16 04:12:51
【问题描述】:

Nginx 返回 110 连接超时

nginx 错误日志

2013/08/14 01:06:25 [error] 29031#0: *19429255 connect() failed (110: Connection timed out) while connecting to upstream, client: ***.***.***.***, server: d.localhost.com, request: "GET /dashboard/d HTTP/1.1", upstream: "http://0.0.0.0:9000/dashboard/d", host: "d.localhost.com", referrer: "http://d.localhost.com/"

我使用 nginx 提供资产文件并减少了播放负载,但我仍然收到此错误 已尝试增加 proxy_connect_timeout , send_timeout , proxy_read_timeout 但错误仍然存​​在 即使服务器负载很低,它也会抛出这些错误

这种情况经常发生在不同的请求中

而我的nginx配置是

upstream dWeb {
server 0.0.0.0:9000; 
}
server {
listen 80;
client_max_body_size 50M;
server_name  d.localhost.com;
root /home/web/d-web;
send_timeout 20;
location /
{
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_redirect off;
    proxy_max_temp_file_size 0;
    proxy_connect_timeout 10000;
    send_timeout 10000;
    proxy_read_timeout 10000;
    keepalive_timeout 10000;
    root /home/web/dsp-web/d-web-0.1.0;
    autoindex on;
    proxy_pass http://dWeb;
    error_log /data/nginxlog/d.rd/error.log;
}
}

【问题讨论】:

  • 你有一个名为 dWeb 的上游,对!你也可以粘贴一下吗
  • 上游 dspWeb { 服务器 0.0.0.0:9000; }
  • 应该是 127.0.0.1:9000 还是 localhost:9000?可以尝试访问 localhost:9000 看看是否可以正确访问。
  • @TroyCheng 当请求数量增加时,proxy_pass 在正常负载下工作正常我对某些请求有 110 超时,所以问题不在于 0.0.0.0:9000;

标签: nginx playframework-2.1 proxypass


【解决方案1】:

实际问题是 play 无法处理发送给它的所有请求,最终连接超时

就像增加 nginx 中的 worker 一样,我们必须增加线程池来提高并行性能

覆盖默认线程池以提高性能

默认配置

play {
  akka {
    event-handlers = ["akka.event.Logging$DefaultLogger","akka.event.slf4j.Slf4jEventHandler"]
    loglevel = WARNING
    actor {
      default-dispatcher = {
        fork-join-executor {
          parallelism-factor = 1.0
          parallelism-max = 24
        }
      }
    }
  }
}

并行度因子是每个可用内核要创建的线程数 将其增加到 4 因为每个请求都有很多读写操作

覆盖的配置 并行系数 = 4.0 并行度-max = 24

这停止了 110 超时错误

【讨论】:

    猜你喜欢
    • 2011-10-12
    • 2014-03-01
    • 2012-12-19
    • 2018-01-31
    • 2016-06-07
    • 2011-08-01
    • 1970-01-01
    • 2021-02-23
    相关资源
    最近更新 更多