From aac6e4bce52fe0da1374aefa936f1ae8a162d1b7 Mon Sep 17 00:00:00 2001 From: jdknives <36450093+jdknives@users.noreply.github.com> Date: Fri, 15 Jul 2022 14:14:14 +0200 Subject: [PATCH 1/2] Disable http transport keepalives This commit disables the http transport keepalives to prevent all clients having permanent open connections to the deployment --- pkg/visor/init.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/visor/init.go b/pkg/visor/init.go index bcb77aca35..381540f8b9 100644 --- a/pkg/visor/init.go +++ b/pkg/visor/init.go @@ -776,7 +776,7 @@ func initHypervisors(ctx context.Context, v *Visor, log *logging.Logger) error { } func initUptimeTracker(ctx context.Context, v *Visor, log *logging.Logger) error { - const tickDuration = 1 * time.Minute + const tickDuration = 5 * time.Minute conf := v.conf.UptimeTracker @@ -1164,7 +1164,11 @@ func getHTTPClient(ctx context.Context, v *Visor, service string) (*http.Client, } return v.dmsgHTTP, nil } - return &http.Client{}, nil + return &http.Client{ + Transport: &http.Transport{ + DisableKeepAlives: true, + }, + }, nil } func getPublicIP(v *Visor, service string) (pIP string, err error) { From 7118486f1caee860b75bafd65c6787a0a7e85a35 Mon Sep 17 00:00:00 2001 From: jdknives <36450093+jdknives@users.noreply.github.com> Date: Wed, 20 Jul 2022 19:07:13 +0200 Subject: [PATCH 2/2] Add IdleConnTimeout of 5 seconds --- pkg/visor/init.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/visor/init.go b/pkg/visor/init.go index 381540f8b9..7e160ec46d 100644 --- a/pkg/visor/init.go +++ b/pkg/visor/init.go @@ -1167,6 +1167,7 @@ func getHTTPClient(ctx context.Context, v *Visor, service string) (*http.Client, return &http.Client{ Transport: &http.Transport{ DisableKeepAlives: true, + IdleConnTimeout: time.Second * 5, }, }, nil }