Browse Source

Merge pull request #2900 from yichengq/proxy-maxidle

etcdmain: increase maxIdleConnsPerHost in proxy transport
Yicheng Qin 10 years ago
parent
commit
1cd5c7efee
2 changed files with 12 additions and 0 deletions
  1. 1 0
      etcdmain/etcd.go
  2. 11 0
      proxy/proxy.go

+ 1 - 0
etcdmain/etcd.go

@@ -248,6 +248,7 @@ func startProxy(cfg *config) error {
 	}
 
 	pt, err := transport.NewTransport(cfg.clientTLSInfo)
+	pt.MaxIdleConnsPerHost = proxy.DefaultMaxIdleConnsPerHost
 	if err != nil {
 		return err
 	}

+ 11 - 0
proxy/proxy.go

@@ -18,6 +18,17 @@ import (
 	"net/http"
 )
 
+const (
+	// DefaultMaxIdleConnsPerHost indicates the default maximal idle connections
+	// maintained between proxy and each member. We set it to 128 to
+	// let proxy handle 128 concurrent requests in long term smoothly.
+	// If the number of concurrent requests is bigger than this value,
+	// proxy needs to create one new connection when handling each request in
+	// the delta, which is bad because the creation consumes resource and
+	// may eat up ephemeral ports.
+	DefaultMaxIdleConnsPerHost = 128
+)
+
 // GetProxyURLs is a function which should return the current set of URLs to
 // which client requests should be proxied. This function will be queried
 // periodically by the proxy Handler to refresh the set of available