bfenetworks / bfe

A modern layer 7 load balancer from baidu
https://www.bfe-networks.net
Apache License 2.0
6.12k stars 946 forks source link

http RoundTripper 支持自动断开空闲连接 #1031

Closed shiw13 closed 2 hours ago

shiw13 commented 2 years ago

问题

本地测试 http 1.1 转发,发现bfe貌似会一直保持和后端服务之间的tcp连接,每条连接会占用2条协程,导致空闲后 协程也还在。

解决方案

bfe能否支持配置 空闲连接超时时间,超时后自动断开。也就是标准库里面的 http.Transport IdleConnTimeout

// IdleConnTimeout is the maximum amount of time an idle
// (keep-alive) connection will remain idle before closing
// itself.
// Zero means no limit.
mileszhang2016 commented 2 years ago

很好的建议。我们后续会考虑一下这个需求。谢谢。

Tovi163 commented 1 year ago

问题

本地测试 http 1.1 转发,发现bfe貌似会一直保持和后端服务之间的tcp连接,每条连接会占用2条协程,导致空闲后 协程也还在。

解决方案

bfe能否支持配置 空闲连接超时时间,超时后自动断开。也就是标准库里面的 http.Transport IdleConnTimeout

// IdleConnTimeout is the maximum amount of time an idle
// (keep-alive) connection will remain idle before closing
// itself.
// Zero means no limit.

是否可以补充下测试方法;另外测试中是否开启了连接池