Skip to content

Commit cd6b5cd

Browse files
jameshoulahancuthix
authored andcommitted
GODT-1348: max 100 conn per host
1 parent 8f1ca00 commit cd6b5cd

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

pkg/pmapi/dialer_basic.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ func CreateTransportWithDialer(dialer TLSDialer) *http.Transport {
3333
return &http.Transport{
3434
DialTLS: dialer.DialTLS,
3535

36-
Proxy: http.ProxyFromEnvironment,
37-
MaxIdleConns: 100,
38-
IdleConnTimeout: 5 * time.Minute,
36+
Proxy: http.ProxyFromEnvironment,
37+
MaxIdleConns: 100,
38+
MaxIdleConnsPerHost: 100,
39+
IdleConnTimeout: 5 * time.Minute,
40+
3941
ExpectContinueTimeout: 500 * time.Millisecond,
4042

4143
// GODT-126: this was initially 10s but logs from users showed a significant number

pkg/pmapi/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func New(cfg Config) Manager {
4343
func newManager(cfg Config) *manager {
4444
m := &manager{
4545
cfg: cfg,
46-
rc: resty.New(),
46+
rc: resty.New().EnableTrace(),
4747
locker: &sync.Mutex{},
4848
}
4949

@@ -59,6 +59,7 @@ func newManager(cfg Config) *manager {
5959
// wrapped in JSON. If error is returned, `handleRequestFailure` is called,
6060
// otherwise `handleRequestSuccess` is called.
6161
m.rc.SetError(&Error{})
62+
m.rc.OnAfterResponse(logConnReuse)
6263
m.rc.OnAfterResponse(updateTime)
6364
m.rc.OnAfterResponse(m.catchAPIError)
6465
m.rc.OnAfterResponse(m.handleRequestSuccess)

pkg/pmapi/response.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ func updateTime(_ *resty.Client, res *resty.Response) error {
8282
return nil
8383
}
8484

85+
func logConnReuse(_ *resty.Client, res *resty.Response) error {
86+
if !res.Request.TraceInfo().IsConnReused {
87+
logrus.WithField("host", res.Request.URL).Trace("Connection was NOT reused")
88+
}
89+
90+
return nil
91+
}
92+
8593
func catchRetryAfter(_ *resty.Client, res *resty.Response) (time.Duration, error) {
8694
if res.StatusCode() == http.StatusTooManyRequests {
8795
if after := res.Header().Get("Retry-After"); after != "" {

0 commit comments

Comments
 (0)