Skip to content

Commit

Permalink
add configs for idle connections in servergroup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpst authored and jacksontj committed Sep 7, 2024
1 parent e9ce3a8 commit 7c5eda6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions pkg/servergroup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import (
var (
// DefaultConfig is the Default base promxy configuration
DefaultConfig = Config{
AntiAffinity: time.Second * 10,
Scheme: "http",
RemoteReadPath: "api/v1/read",
Timeout: 0,
IdleConnTimeout: 5 * time.Minute,
PreferMax: false,
AntiAffinity: time.Second * 10,
Scheme: "http",
RemoteReadPath: "api/v1/read",
Timeout: 0,
MaxIdleConns: 20000,
MaxIdleConnsPerHost: 1000,
IdleConnTimeout: 5 * time.Minute,
PreferMax: false,
HTTPConfig: HTTPClientConfig{
DialTimeout: time.Millisecond * 200, // Default dial timeout of 200ms
},
Expand Down Expand Up @@ -149,7 +151,13 @@ type Config struct {
// time does not include the time to read the response body.
Timeout time.Duration `yaml:"timeout,omitempty"`

// IdleConnTimeout, if non-zero, time wait to close a idle connections.
// MaxIdleConns, servergroup maximum number of idle connections to keep open.
MaxIdleConns int `yaml:"max_idle_conns,omitempty"`

// MaxIdleConnsPerHost, servergroup maximum number of idle connections to keep open per host.
MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host,omitempty"`

// IdleConnTimeout, time wait to close a idle connections.
IdleConnTimeout time.Duration `yaml:"idle_conn_timeout,omitempty"`

// IgnoreError will hide all errors from this given servergroup effectively making
Expand Down
4 changes: 2 additions & 2 deletions pkg/servergroup/servergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ func (s *ServerGroup) ApplyConfig(cfg *Config) error {
// It is applied on request. So we leave out any timings here.
var rt http.RoundTripper = &http.Transport{
Proxy: http.ProxyURL(cfg.HTTPConfig.HTTPConfig.ProxyURL.URL),
MaxIdleConns: 20000,
MaxIdleConnsPerHost: 1000, // see https://github.com/golang/go/issues/13801
MaxIdleConns: cfg.MaxIdleConns,
MaxIdleConnsPerHost: cfg.MaxIdleConnsPerHost, // see https://github.com/golang/go/issues/13801
DisableKeepAlives: false,
TLSClientConfig: tlsConfig,
// 5 minutes is typically above the maximum sane scrape interval. So we can
Expand Down

0 comments on commit 7c5eda6

Please sign in to comment.