【发布时间】: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 不会影响任何事情。
帮助?
堆栈配置:
- nginx 版本:nginx/1.10.3 (Ubuntu)
- uwsgi 2.0.17
- Python 2.7.12
- 烧瓶==0.12.2
【问题讨论】:
-
您好,您解决了这个问题吗?我也面临同样的问题。
-
不确定,但我认为这是我的应用程序代码管理不善的问题
-
感谢 Mouli,您的回复。我转向了 Apache。