Skip to content

Commit 4b709c0

Browse files
committed
fix: default MaxIdleConnsPerHost/MaxIdleConns base on cpu
1 parent 57524a0 commit 4b709c0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/courierhttp/client/http_default.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/tls"
66
"net"
77
"net/http"
8+
"runtime"
89
"time"
910

1011
"golang.org/x/net/http2"
@@ -18,8 +19,8 @@ var reasonableRoundTripper = &http.Transport{
1819
KeepAlive: 30 * time.Second,
1920
}).DialContext),
2021

21-
MaxIdleConns: 100,
22-
MaxIdleConnsPerHost: 10,
22+
MaxIdleConns: 100 * runtime.NumCPU(),
23+
MaxIdleConnsPerHost: 10 * runtime.NumCPU(),
2324
IdleConnTimeout: 90 * time.Second,
2425

2526
TLSHandshakeTimeout: 10 * time.Second,

0 commit comments

Comments
 (0)