Nginx超时,当uWSGI需要很长时间来处理请求 [英] Nginx timeouts when uWSGI takes long to process request

查看:1164
本文介绍了Nginx超时,当uWSGI需要很长时间来处理请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有适用于Python Django应用程式的Nginx + uWSGI。

I have Nginx + uWSGI for Python Django app.

我在 nginx.conf 中有以下内容:

location / {
    include uwsgi_params;
    uwsgi_pass   127.0.0.1:9001;
    uwsgi_read_timeout 1800;
    uwsgi_send_timeout 300;
    client_header_timeout 300;
    proxy_read_timeout 300;
    index  index.html index.htm;
}

但对于uWSGI上长时间运行的请求,大约需要1分钟才能完成Nginx错误日志中的超时错误如下:

but for long running requests on uWSGI which takes about 1 minute to complete I get a timeout error in Nginx error log as below:


2013/04/22 12:35:56 [error] 2709#0: 1上游超时(110:连接超时),同时从上游读取响应头,客户端:xx.xx.xx.xx,服务器:请求:GET / entity / datasenders / HTTP / 1.1,upstream:uwsgi: //127.0.0.1:9001,host:xxx.xx.xx.x

2013/04/22 12:35:56 [error] 2709#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xx.xx.xx.xx, server: , request: "GET /entity/datasenders/ HTTP/1.1", upstream: "uwsgi://127.0.0.1:9001", host: "xxx.xx.xx.x"

我已经设置标题时间

推荐答案

location / {
    include uwsgi_params;
    uwsgi_pass   127.0.0.1:9001;
    uwsgi_read_timeout 300;
    index  index.html index.htm;
}

问题中的上述配置对我们不起作用的原因,我们的机器多个路径有 nginx.conf 文件。我们正在与错误的路径工作。

The reason the above configuration in the question did not work for us because unfortunately in our machine multiple paths had nginx.conf file. We were working with the conf at the wrong path.

要正确确定nginx从运行中获取配置的路径:

To correctly figure out which path your nginx is picking up the configuration from run:

nginx -V  # V is caps

这将有一个 - conf-path = [] 它会告诉你从哪里获取配置。

this will have a --conf-path=[] which will tell you exactly from where it is picking up the configuration from.

我最近发现上面 nginx -V 不给正确的信息。我会离开上述,以防其他人觉得有用。

I recently found the above nginx -V to not give the right info. I will leave the above just in case others find it useful.

这篇关于Nginx超时,当uWSGI需要很长时间来处理请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆