mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 21:22:15 +08:00
HTTP Client: Introduce dataproxy_max_idle_connections
config variable (#35864)
* Introduce dataproxy_max_idle_connections config var * Fix according to reviewer's comments * Fix according to reviewer's comments - round 2 * Remove unused const * Bring back MaxIdleConnsPerHost * Fixes according to reviewer's comments
This commit is contained in:

committed by
GitHub

parent
d1da97b176
commit
069fb0cf38
@ -166,9 +166,6 @@ max_conns_per_host = 0
|
||||
# The maximum number of idle connections that Grafana will keep alive.
|
||||
max_idle_connections = 100
|
||||
|
||||
# The maximum number of idle connections per host that Grafana will keep alive.
|
||||
max_idle_connections_per_host = 2
|
||||
|
||||
# How many seconds the data proxy keeps an idle connection open before timing out.
|
||||
idle_conn_timeout_seconds = 90
|
||||
|
||||
|
@ -172,9 +172,6 @@
|
||||
# The maximum number of idle connections that Grafana will keep alive.
|
||||
;max_idle_connections = 100
|
||||
|
||||
# The maximum number of idle connections per host that Grafana will keep alive.
|
||||
;max_idle_connections_per_host = 2
|
||||
|
||||
# How many seconds the data proxy keeps an idle connection open before timing out.
|
||||
;idle_conn_timeout_seconds = 90
|
||||
|
||||
|
@ -424,6 +424,7 @@ For more details check the [Transport.MaxConnsPerHost](https://golang.org/pkg/ne
|
||||
The maximum number of idle connections that Grafana will maintain. Default is `100`. For more details check the [Transport.MaxIdleConns](https://golang.org/pkg/net/http/#Transport.MaxIdleConns) documentation.
|
||||
|
||||
### max_idle_connections_per_host
|
||||
[Deprecated - use max_idle_connections instead]
|
||||
|
||||
The maximum number of idle connections per host that Grafana will maintain. Default is `2`. For more details check the [Transport.MaxIdleConnsPerHost](https://golang.org/pkg/net/http/#Transport.MaxIdleConnsPerHost) documentation.
|
||||
|
||||
|
@ -84,19 +84,20 @@ func (ds *DataSource) GetHTTPTransport(provider httpclient.Provider, customMiddl
|
||||
|
||||
func (ds *DataSource) HTTPClientOptions() sdkhttpclient.Options {
|
||||
tlsOptions := ds.TLSOptions()
|
||||
timeouts := &sdkhttpclient.TimeoutOptions{
|
||||
Timeout: ds.getTimeout(),
|
||||
DialTimeout: time.Duration(setting.DataProxyDialTimeout) * time.Second,
|
||||
KeepAlive: time.Duration(setting.DataProxyKeepAlive) * time.Second,
|
||||
TLSHandshakeTimeout: time.Duration(setting.DataProxyTLSHandshakeTimeout) * time.Second,
|
||||
ExpectContinueTimeout: time.Duration(setting.DataProxyExpectContinueTimeout) * time.Second,
|
||||
MaxConnsPerHost: setting.DataProxyMaxConnsPerHost,
|
||||
MaxIdleConns: setting.DataProxyMaxIdleConns,
|
||||
MaxIdleConnsPerHost: setting.DataProxyMaxIdleConns,
|
||||
IdleConnTimeout: time.Duration(setting.DataProxyIdleConnTimeout) * time.Second,
|
||||
}
|
||||
opts := sdkhttpclient.Options{
|
||||
Timeouts: &sdkhttpclient.TimeoutOptions{
|
||||
Timeout: ds.getTimeout(),
|
||||
DialTimeout: time.Duration(setting.DataProxyDialTimeout) * time.Second,
|
||||
KeepAlive: time.Duration(setting.DataProxyKeepAlive) * time.Second,
|
||||
TLSHandshakeTimeout: time.Duration(setting.DataProxyTLSHandshakeTimeout) * time.Second,
|
||||
ExpectContinueTimeout: time.Duration(setting.DataProxyExpectContinueTimeout) * time.Second,
|
||||
MaxConnsPerHost: setting.DataProxyMaxConnsPerHost,
|
||||
MaxIdleConns: setting.DataProxyMaxIdleConns,
|
||||
MaxIdleConnsPerHost: setting.DataProxyMaxIdleConnsPerHost,
|
||||
IdleConnTimeout: time.Duration(setting.DataProxyIdleConnTimeout) * time.Second,
|
||||
},
|
||||
Headers: getCustomHeaders(ds.JsonData, ds.DecryptedValues()),
|
||||
Timeouts: timeouts,
|
||||
Headers: getCustomHeaders(ds.JsonData, ds.DecryptedValues()),
|
||||
Labels: map[string]string{
|
||||
"datasource_name": ds.Name,
|
||||
"datasource_uid": ds.Uid,
|
||||
|
@ -850,11 +850,15 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
||||
DataProxyTLSHandshakeTimeout = dataproxy.Key("tls_handshake_timeout_seconds").MustInt(10)
|
||||
DataProxyExpectContinueTimeout = dataproxy.Key("expect_continue_timeout_seconds").MustInt(1)
|
||||
DataProxyMaxConnsPerHost = dataproxy.Key("max_conns_per_host").MustInt(0)
|
||||
DataProxyMaxIdleConns = dataproxy.Key("max_idle_connections").MustInt(100)
|
||||
DataProxyMaxIdleConnsPerHost = dataproxy.Key("max_idle_connections_per_host").MustInt(2)
|
||||
DataProxyMaxIdleConns = dataproxy.Key("max_idle_connections").MustInt()
|
||||
DataProxyIdleConnTimeout = dataproxy.Key("idle_conn_timeout_seconds").MustInt(90)
|
||||
cfg.SendUserHeader = dataproxy.Key("send_user_header").MustBool(false)
|
||||
|
||||
if val, err := dataproxy.Key("max_idle_connections_per_host").Int(); err == nil {
|
||||
cfg.Logger.Warn("[Deprecated] the configuration setting 'max_idle_connections_per_host' is deprecated, please use 'max_idle_connections' instead")
|
||||
DataProxyMaxIdleConns = val
|
||||
}
|
||||
|
||||
if err := readSecuritySettings(iniFile, cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user