首页 > 解决方案 > Gunicorn + nginx - 忽略 EPIPE

问题描述

我有一个在谷歌计算上运行的 nginx-gunicorn-flask 设置,我不断从 gunicorn 获得以下信息:

[2019-04-19 20:50:49 +0000] [3345] [DEBUG] POST /
[2019-04-19 20:50:49 +0000] [3345] [DEBUG] Ignoring EPIPE

在 100 个请求中,大约有 23 个是这样出现的。在访问日志中仅显示 23 个请求,它们都是 200 个。

从 nginx 访问日志显示 504,在错误日志中我看到:

2019/04/19 20:50:49 [error] 3097#3097: *295 upstream timed out (110: Connection timed out) while sending request to upstream, client: ip, server: , request: "POST / HTTP/1.1", upstream: "http://unix:/home/user/Server/server.sock/", host: "ip"

我试过设置

proxy_connect_timeout 75s;
proxy_read_timeout 300s;

--timeout 300根据其他问题在 nginx 和 gunicorn 上的位置,但它没有帮助。

来自 gunicorn 的消息并没有真正帮助确定原因,我没有找到任何有关它的信息

一直试图解决这个问题,我会很感激任何想法。此外,这些请求中的每一个都需要大约 1-2 秒,并且 jmeter 显示出巨大的延迟,直到结果出现。

查看 gunicorn 的代码,这是一个与套接字有关的 errno.EPIPE 异常......

标签: pythonnginxservergunicornubuntu-18.04

解决方案


我遇到了类似的问题和超时错误,除了增加超时值,添加 Nginx 配置proxy_ignore_client_abort on;检查这个线程Nginx doc

proxy_ignore_client_abort on;

推荐阅读