我已经部署了一个使用uWSGI和NGINX作为反向代理的flask web应用程序。应用程序的响应时间平均约为9ms,但在一批请求之后,我的工作人员崩溃了,我在uWSGI日志上得到了以下日志:
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 24488] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 4059] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 46764] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 9951] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 9449] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 51355] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 39565] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 63142] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 7861] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 10165] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 10917] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
[uwsgi-http key: backend client_addr: 172.17.0.1 client_port: 20392] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
uWSGI配置:
[uwsgi]
http = 0.0.0.0:7000
wsgi-file = app.py
callable = app
processes = 5
lazy = true
lazy-apps = true
buffer-size = 16384
logto = /root/logs/data-gathering.log
环境:
uWSGI==2.0.17
Flask==0.12.2
1条答案
按热度按时间ha5z0ras1#
我在uWSGI本地HTTP服务器上遇到了同样的问题。具有以下配置:
我总是得到:
在我的例子中,我正在执行POST请求,而不是消耗身体。因此,在将
post-buffering = 1
添加到配置后,一切都开始正常工作。没有标志,仅阅读POST数据,结果相同。从uWSGI的“要知道的事情”:
如果一个HTTP请求有一个主体(就像一个表单生成的POST请求),你必须在你的应用程序中读取(消费)它。如果你不这样做,与你的网络服务器的通信套接字可能会被破坏。如果你很懒,你可以使用后缓冲选项,它会自动为你读取数据。对于Rack应用程序,此选项自动启用。