Skip to content

Commit

Permalink
update max number of iddle conns in client transport
Browse files Browse the repository at this point in the history
  • Loading branch information
imjaroiswebdev committed Aug 16, 2024
1 parent a944382 commit 906fe59
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pagerduty/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down Expand Up @@ -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}
}
Expand Down
8 changes: 8 additions & 0 deletions pagerdutyplugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down

0 comments on commit 906fe59

Please sign in to comment.