From f1d87fd3cc2f3f46c953b67573f4fad3215c2ff1 Mon Sep 17 00:00:00 2001 From: Matthew Jaffee Date: Mon, 6 Nov 2017 10:23:07 -0600 Subject: [PATCH] bump MaxIdleConns(PerHost) like v0.7 This helps "connection reset" issues when the cluster is under high query load from many clients. This also brings in the default http transport options which were (mistakenly?) removed by the TLS work. I'm not sure what the ramifications would be of using a blank http.Transport{} instead of http.DefaultTransport, but it seems best to avoid a sweeping change. --- client.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 0a893ddf9..666447586 100644 --- a/client.go +++ b/client.go @@ -25,6 +25,7 @@ import ( "io/ioutil" "log" "math/rand" + "net" "net/http" "net/url" "sort" @@ -70,7 +71,19 @@ func NewInternalHTTPClientFromURI(defaultURI *URI, options *ClientOptions) *Inte if options == nil { options = &ClientOptions{} } - transport := &http.Transport{} + transport := &http.Transport{ + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + DualStack: true, + }).DialContext, + MaxIdleConns: 1000, + MaxIdleConnsPerHost: 200, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, + } if options.TLS != nil { transport.TLSClientConfig = options.TLS }