【问题标题】:nginx uwsgi upstream timed out (110: Connection timed out) while reading upstream读取上游时 nginx uwsgi 上游超时(110:连接超时)
【发布时间】:2021-09-10 02:56:06
【问题描述】:

我有一个 python flask 应用程序,它输出 300kb 周围的请求。

此应用程序通过uwsgi emperor 托管,配置如下。

[uwsgi]
chdir = /var/www/%n

socket = /etc/uwsgi/sockets/%n.sock
chmod-socket = 660
vaccum = true

processes = 4
threads = 20

virtualenv = /var/www/%n/.venv
module = app:app
logto = /var/log/uwsgi/%n.log

uwsgi 日志有以下行

[pid: 16668|app: 0|req: 1/1] 127.0.0.1 () {46 vars in 700 bytes} [Wed May  2 04:56:24 2018] POST /context-path => generated 293595 bytes in 34172 msecs (HTTP/1.1 200) 2 headers in 75 bytes (3 switches on core 0)
announcing my loyalty to the Emperor...

nginx 的配置是

location /context-path {
    include uwsgi_params;
    uwsgi_pass unix:/etc/uwsgi/sockets/app.sock;
    uwsgi_read_timeout 300;
}

在 5 分钟结束时,我在 nginx error.log 看到以下内容

2018/05/02 05:13:42 [error] 16994#16994: *7 upstream timed out (110: Connection timed out) while reading upstream, client: 127.0.0.1, server: 127.0.0.1, request: "POST /context-path HTTP/1.1", upstream: "uwsgi://unix:/etc/uwsgi/sockets/app.sock:", host: "127.0.0.1"

我在 5 分钟后收到部分数据。 增加uwsgi_read_timeout 不会影响任何事情。

帮助?

堆栈配置:

  1. nginx 版本:nginx/1.10.3 (Ubuntu)
  2. uwsgi 2.0.17
  3. Python 2.7.12
  4. 烧瓶==0.12.2

【问题讨论】:

  • 您好,您解决了这个问题吗?我也面临同样的问题。
  • 不确定,但我认为这是我的应用程序代码管理不善的问题
  • 感谢 Mouli,您的回复。我转向了 Apache。

标签: nginx flask uwsgi


【解决方案1】:

据我所知,许多不同的上游选项都可能出现此错误消息。

ngx_http_upstream_module 模块用于定义可由 proxy_pass、fastcgi_pass、uwsgi_pass、scgi_pass、memcached_pa​​ss 和 grpc_pass 指令引用的服务器组。

我使用 nginx 作为与其他服务器的负载平衡器,使用 proxy_pass。所以我需要一个 proxy_* 超时选项,例如 proxy_read_timeout,来修复这个错误。

【讨论】:

    猜你喜欢
    • 2014-03-01
    • 2013-09-15
    • 2018-01-31
    • 2011-08-01
    • 2021-06-01
    • 1970-01-01
    • 2018-05-19
    • 2012-12-19
    • 2018-10-15
    相关资源
    最近更新 更多