From 6ee6f72c48e51053f493e6ff974a5f495635b400 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Mon, 1 Jun 2015 16:10:44 -0700 Subject: [PATCH] etcdmain: increase maxIdleConnsPerHost in proxy transport This PR set maxIdleConnsPerHost 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 your ephemeral port. --- etcdmain/etcd.go | 1 + proxy/proxy.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/etcdmain/etcd.go b/etcdmain/etcd.go index e2a7d820f..d2fb21ab4 100644 --- a/etcdmain/etcd.go +++ b/etcdmain/etcd.go @@ -233,6 +233,7 @@ func startProxy(cfg *config) error { } pt, err := transport.NewTransport(cfg.clientTLSInfo) + pt.MaxIdleConnsPerHost = proxy.DefaultMaxIdleConnsPerHost if err != nil { return err } diff --git a/proxy/proxy.go b/proxy/proxy.go index f95f6b88f..295fede53 100644 --- a/proxy/proxy.go +++ b/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