Skip to content

Commit d09a6c4

Browse files
committed
document client configuration constants
Signed-off-by: Etai Lev Ran <[email protected]>
1 parent daca615 commit d09a6c4

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pkg/epp/datalayer/metrics/client.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,25 @@ type Client interface {
3333
Get(ctx context.Context, target *url.URL, ep datalayer.Addressable) (PrometheusMetricMap, error)
3434
}
3535

36-
// -- package implementations --
3736
const (
37+
// the maximum idle connection count is shared by all endpoints. The value is
38+
// set high to ensure the number of idle connection is above the expected
39+
// endpoint count. Setting it too low would cause thrashing of the idle connection
40+
// pool and incur higher overheads for every GET (e.g., socket initiation, certificate
41+
// exchange, connections in timed wait state, etc.).
3842
maxIdleConnections = 5000
39-
maxIdleTime = 10 * time.Second
40-
timeout = 10 * time.Second
43+
maxIdleTime = 10 * time.Second // once a endpoint goes down, allow closing.
44+
timeout = 10 * time.Second // mostly guard against unresponsive endpoints.
45+
// allow some grace when connections are not made idle immediately (e.g., parsing
46+
// and updating might take some time). This allows maintaining up to two idle connections
47+
// per endpoint (defined as scheme://host:port).
48+
maxIdleConnsPerHost = 2
4149
)
4250

4351
var (
4452
baseTransport = &http.Transport{
4553
MaxIdleConns: maxIdleConnections,
46-
MaxIdleConnsPerHost: 4, // host is defined as scheme://host:port
54+
MaxIdleConnsPerHost: maxIdleConnsPerHost,
4755
// TODO: set additional timeouts, transport options, etc.
4856
}
4957
defaultClient = &client{

0 commit comments

Comments
 (0)