From 906fe594aff4a399a483853513d1b33cbc02a09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Reyes?= Date: Fri, 16 Aug 2024 16:11:26 -0400 Subject: [PATCH] update max number of iddle conns in client transport --- pagerduty/config.go | 17 +++++++++++++++++ pagerdutyplugin/config.go | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/pagerduty/config.go b/pagerduty/config.go index 5d81461e6..93c40f6a7 100644 --- a/pagerduty/config.go +++ b/pagerduty/config.go @@ -79,6 +79,14 @@ func (c *Config) Client() (*pagerduty.Client, error) { httpClient.Timeout = 2 * time.Minute transport := http.DefaultTransport.(*http.Transport).Clone() + // Set the maximum number of idle (keep-alive) connections across all hosts + // Experimenting with these values to see if it helps with the connection pool + // and hence to solve the issue + // https://github.com/PagerDuty/terraform-provider-pagerduty/issues/904 + transport.MaxIdleConns = 0 + transport.MaxIdleConnsPerHost = 500 + transport.MaxConnsPerHost = 0 + if c.InsecureTls { transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} } @@ -142,8 +150,17 @@ func (c *Config) SlackClient() (*pagerduty.Client, error) { var httpClient *http.Client httpClient = http.DefaultClient + httpClient.Timeout = 2 * time.Minute transport := http.DefaultTransport.(*http.Transport).Clone() + // Set the maximum number of idle (keep-alive) connections across all hosts + // Experimenting with these values to see if it helps with the connection pool + // and hence to solve the issue + // https://github.com/PagerDuty/terraform-provider-pagerduty/issues/904 + transport.MaxIdleConns = 0 + transport.MaxIdleConnsPerHost = 500 + transport.MaxConnsPerHost = 0 + if c.InsecureTls { transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} } diff --git a/pagerdutyplugin/config.go b/pagerdutyplugin/config.go index 5ab319d8e..9c92554bf 100644 --- a/pagerdutyplugin/config.go +++ b/pagerdutyplugin/config.go @@ -79,6 +79,14 @@ func (c *Config) Client(ctx context.Context) (*pagerduty.Client, error) { httpClient.Timeout = 2 * time.Minute transport := http.DefaultTransport.(*http.Transport).Clone() + // Set the maximum number of idle (keep-alive) connections across all hosts + // Experimenting with these values to see if it helps with the connection pool + // and hence to solve the issue + // https://github.com/PagerDuty/terraform-provider-pagerduty/issues/904 + transport.MaxIdleConns = 0 + transport.MaxIdleConnsPerHost = 500 + transport.MaxConnsPerHost = 0 + if c.InsecureTls { transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} }