graphite报错:upstream prematurely closed connection while reading response header from upstream

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liuxiao723846/article/details/82842523

线上监控系统使用grafana+graphite,graphite使用nginx+uwsgi启动。有一次在grafana上监控图出现错误,显示响应式502,于是先检查graphite-web,发现在graphite-web界面上偶尔打不开。

然后再nginx的error日志上显示如下信息:

2018/09/25 17:05:04 [error] 20967#0: *640 upstream prematurely closed connection while reading response header from upstream, client: 110.39.12.24, server: localhost, request: "POST /render HTTP/1.1", upstream: "uwsgi://127.0.0.1:9090", host: "110.39.12.24"

graphite-web是django写的,找一篇文章”django upstream prematurely closed connection while reading response header from up“,解决方法如下:

1.必须要在uwsgi.ini中设置“limit-as”,该值是每个uwsgi进程占用的虚拟内存的最大限制。
2.检查nginx上是否设置了

proxy_http_version 1.1;
proxy_set_header Connection "";

Nginx默认使用HTTP1.0从后端获取响应返还给客户端,但是HTTP1.0不支持keepalive,因此需要配置proxy_http_version 1.1,proxy_set_header Connection默认close:通知后端服务器主动关闭连接,这样会导致任何一个客户端的请求都在后端服务器上产生了一个TIME-WAIT状态的连接。
3.检查uwsgi和Nginx中设置的各种timeout是否过短。
 

参考:

https://blog.csdn.net/lj1404536198/article/details/79138379

猜你喜欢

转载自blog.csdn.net/liuxiao723846/article/details/82842523
今日推荐