From 61ef60c787d1d1682bb5ffb54d2dd45ffaa7aeb3 Mon Sep 17 00:00:00 2001 From: Rueian Date: Thu, 5 Dec 2019 01:13:27 +0800 Subject: [PATCH] bug(cloudflared): Set the MaxIdleConnsPerHost of http.Transport to proxy-keepalive-connections Setting the MaxIdleConns is not enough, the MaxIdleConnsPerHost must be set as well. Otherwise, http.Transport will use the DefaultMaxIdleConnsPerHost, which is 2, and then the connection pool will have only 2 connection hold. --- cmd/cloudflared/tunnel/configuration.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/cloudflared/tunnel/configuration.go b/cmd/cloudflared/tunnel/configuration.go index 8986c9f9..5a42f3a9 100644 --- a/cmd/cloudflared/tunnel/configuration.go +++ b/cmd/cloudflared/tunnel/configuration.go @@ -197,6 +197,7 @@ func prepareTunnelConfig( httpTransport := &http.Transport{ Proxy: http.ProxyFromEnvironment, MaxIdleConns: c.Int("proxy-keepalive-connections"), + MaxIdleConnsPerHost: c.Int("proxy-keepalive-connections"), IdleConnTimeout: c.Duration("proxy-keepalive-timeout"), TLSHandshakeTimeout: c.Duration("proxy-tls-timeout"), ExpectContinueTimeout: 1 * time.Second,