问题描述:
项目使用Nginx + uWSGI + Python Flaks 提供Restful API服务,用户反馈同一个服务,部分请求会出现502 Bad Gateway Error,部分请求正常返回。
问题分析:
检查uWSGI 日志,发现有如下错误日志
uwsgi invalid request block size: 5922 (max 4096)...skip
可见是因为request header过大超过uWSGI默认设置导致请求被丢弃,需要更改配置。
官网解释 :uwsgi server is discarding request because of invalid request block size, By default, uWSGI allocates a very small buffer (4096 bytes) for the headers of each request. If receiving “invalid request block size” in logs, it could mean server need a bigger buffer. Increase it (up to 65535) with the buffer-size option.
(If you receive ‘21573’ as the request block size in your logs, it could mean you are using the HTTP protocol to speak with an instance speaking the uwsgi protocol. Don’t do this.)
为什么reques