Remove "Connection" close instead reduce MaxConns per host (#7654)

This is necessary to avoid connection build up between servers
unexpectedly for example in a situation where 16 servers are
talking to each other and one server now allows a maximum of

15*4096 = 61440 idle connections

Will be kept in pool. Such a large pool is perhaps inefficient for
many reasons and also affects overall system resources.

This PR also reduces idleConnection timeout from 120 secs to 60 secs.
master
Harshavardhana 6 years ago committed by Nitish Tiwari
parent c871456269
commit 16c648b109
  1. 5
      cmd/rest/client.go
  2. 1
      cmd/storage-rest-server.go

@ -100,9 +100,8 @@ func NewClient(url *url.URL, tlsConfig *tls.Config, timeout time.Duration, newAu
tr := &http.Transport{ tr := &http.Transport{
Proxy: http.ProxyFromEnvironment, Proxy: http.ProxyFromEnvironment,
DialContext: newCustomDialContext(timeout), DialContext: newCustomDialContext(timeout),
MaxIdleConnsPerHost: 4096, MaxIdleConnsPerHost: 256,
MaxIdleConns: 4096, IdleConnTimeout: 60 * time.Second,
IdleConnTimeout: 120 * time.Second,
TLSHandshakeTimeout: 30 * time.Second, TLSHandshakeTimeout: 30 * time.Second,
ExpectContinueTimeout: 10 * time.Second, ExpectContinueTimeout: 10 * time.Second,
TLSClientConfig: tlsConfig, TLSClientConfig: tlsConfig,

@ -415,7 +415,6 @@ func (s *storageRESTServer) WalkHandler(w http.ResponseWriter, r *http.Request)
} }
defer w.(http.Flusher).Flush() defer w.(http.Flusher).Flush()
w.Header().Set("Connection", "close") // Pro-actively ask client to close this connection.
encoder := gob.NewEncoder(w) encoder := gob.NewEncoder(w)
for fi := range fch { for fi := range fch {
encoder.Encode(&fi) encoder.Encode(&fi)

Loading…
Cancel
Save