From 7b2ebef877534570a3408e05030cb3ea188853de Mon Sep 17 00:00:00 2001 From: kanesong Date: Sun, 24 Apr 2022 11:42:20 +0800 Subject: [PATCH] perf(custom-proxy): disable keepalive to avoid 502 and timeout (#1860) Co-authored-by: kanesong --- .../registry/cluster/storage/customresource_proxy.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/platform/registry/cluster/storage/customresource_proxy.go b/pkg/platform/registry/cluster/storage/customresource_proxy.go index 71211a47f..709c498fc 100644 --- a/pkg/platform/registry/cluster/storage/customresource_proxy.go +++ b/pkg/platform/registry/cluster/storage/customresource_proxy.go @@ -128,11 +128,13 @@ func (n *CustomResourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request Host: strings.TrimPrefix(config.Host, "https://"), }) reserveProxy.Transport = &http.Transport{ + DisableKeepAlives: true, DialContext: (&net.Dialer{ - Timeout: 30 * time.Second, + Timeout: 5 * time.Second, KeepAlive: 30 * time.Second, }).DialContext, - MaxIdleConns: 100, + MaxIdleConns: 1000, + MaxIdleConnsPerHost: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second,