uwsgi_response_write_body_do()TIMEOUT - 但uwsgi_read_timeout没有帮助(x-post)

时间:2015-07-20 17:26:45

标签: python nginx flask uwsgi

我在与Nginx接口时遇到此错误:

@PostAuthorize

它一般都很好。这种情况只发生在我使用50多个并发连接进行测试时,会发送一个发送200MB数据的方法。

我一直在搜索,但我看到所有人都建议增加uwsgi_read_timeout: - (

(我在uwsgi github页面上问道,但是我在想,因为它可能不是一个错误,在这里问一下这个问题更好)

以下是我发布uwsgi的方式:

@PostFilter

这是/etc/nginx/nginx.conf:

uwsgi_response_write_body_do() TIMEOUT !!!
IOError: write error

这是/etc/nginx/conf.d/default.conf:

flask/bin/uwsgi -s 127.0.0.1:9001 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_01.log
flask/bin/uwsgi -s 127.0.0.1:9002 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_02.log
flask/bin/uwsgi -s 127.0.0.1:9003 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_03.log
flask/bin/uwsgi -s 127.0.0.1:9004 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_04.log
flask/bin/uwsgi -s 127.0.0.1:9005 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_05.log
flask/bin/uwsgi -s 127.0.0.1:9006 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_06.log
flask/bin/uwsgi -s 127.0.0.1:9007 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_07.log
flask/bin/uwsgi -s 127.0.0.1:9008 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_08.log
flask/bin/uwsgi -s 127.0.0.1:9009 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_09.log
flask/bin/uwsgi -s 127.0.0.1:9010 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_10.log
flask/bin/uwsgi -s 127.0.0.1:9011 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_11.log
flask/bin/uwsgi -s 127.0.0.1:9012 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_12.log
flask/bin/uwsgi -s 127.0.0.1:9013 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_13.log
flask/bin/uwsgi -s 127.0.0.1:9014 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_14.log
flask/bin/uwsgi -s 127.0.0.1:9015 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_15.log
flask/bin/uwsgi -s 127.0.0.1:9016 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_16.log
flask/bin/uwsgi -s 127.0.0.1:9017 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_17.log
flask/bin/uwsgi -s 127.0.0.1:9018 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_18.log
flask/bin/uwsgi -s 127.0.0.1:9019 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_19.log
flask/bin/uwsgi -s 127.0.0.1:9020 --need-app --wsgi-file app.py --processes 1 --callable app --daemonize /opt/logs/KVAutobus-uwsgi_20.log

1 个答案:

答案 0 :(得分:0)

只需使用指令:

uwsgi_max_temp_file_size 0;

uwsgi_buffering off;

在Nginx中禁用缓冲区。

我认为从nginx到客户端的传输速度远远低于从uwsgi到nginx的速度。并且nginx的缓冲区已满,所以uwsgi等待很长时间才能让nginx接收新数据,这会使uwsgi的写请求超时。

您可以在我的博客中阅读有关此问题的分析:http://kmiku7.github.io/2018/02/02/Solve-the-problem-of-uwsgi-uwsgi-response-write-body-do-TIMEOUT-error/