Skip to content

Commit

Permalink
Set MaxIdleConnsPerHost alongside MaxIdleConns (prometheus#3592)
Browse files Browse the repository at this point in the history
Otherwise it defaults to 2, and Go will close extra connections as
soon as a request is finished.
See golang/go#13801
  • Loading branch information
bboreham authored and brian-brazil committed Dec 17, 2017
1 parent 9083d41 commit a8cce41
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions util/httputil/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ func NewClientFromConfig(cfg config.HTTPClientConfig, name string) (*http.Client
// The only timeout we care about is the configured scrape timeout.
// It is applied on request. So we leave out any timings here.
var rt http.RoundTripper = &http.Transport{
Proxy: http.ProxyURL(cfg.ProxyURL.URL),
MaxIdleConns: 20000,
DisableKeepAlives: false,
TLSClientConfig: tlsConfig,
DisableCompression: true,
Proxy: http.ProxyURL(cfg.ProxyURL.URL),
MaxIdleConns: 20000,
MaxIdleConnsPerHost: 1000, // see https://github.com/golang/go/issues/13801
DisableKeepAlives: false,
TLSClientConfig: tlsConfig,
DisableCompression: true,
// 5 minutes is typically above the maximum sane scrape interval. So we can
// use keepalive for all configurations.
IdleConnTimeout: 5 * time.Minute,
Expand Down

0 comments on commit a8cce41

Please sign in to comment.