mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 04:22:13 +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.
|
# The maximum number of idle connections that Grafana will keep alive.
|
||||||
max_idle_connections = 100
|
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.
|
# How many seconds the data proxy keeps an idle connection open before timing out.
|
||||||
idle_conn_timeout_seconds = 90
|
idle_conn_timeout_seconds = 90
|
||||||
|
|
||||||
|
@ -172,9 +172,6 @@
|
|||||||
# The maximum number of idle connections that Grafana will keep alive.
|
# The maximum number of idle connections that Grafana will keep alive.
|
||||||
;max_idle_connections = 100
|
;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.
|
# How many seconds the data proxy keeps an idle connection open before timing out.
|
||||||
;idle_conn_timeout_seconds = 90
|
;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.
|
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
|
### 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.
|
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,8 +84,7 @@ func (ds *DataSource) GetHTTPTransport(provider httpclient.Provider, customMiddl
|
|||||||
|
|
||||||
func (ds *DataSource) HTTPClientOptions() sdkhttpclient.Options {
|
func (ds *DataSource) HTTPClientOptions() sdkhttpclient.Options {
|
||||||
tlsOptions := ds.TLSOptions()
|
tlsOptions := ds.TLSOptions()
|
||||||
opts := sdkhttpclient.Options{
|
timeouts := &sdkhttpclient.TimeoutOptions{
|
||||||
Timeouts: &sdkhttpclient.TimeoutOptions{
|
|
||||||
Timeout: ds.getTimeout(),
|
Timeout: ds.getTimeout(),
|
||||||
DialTimeout: time.Duration(setting.DataProxyDialTimeout) * time.Second,
|
DialTimeout: time.Duration(setting.DataProxyDialTimeout) * time.Second,
|
||||||
KeepAlive: time.Duration(setting.DataProxyKeepAlive) * time.Second,
|
KeepAlive: time.Duration(setting.DataProxyKeepAlive) * time.Second,
|
||||||
@ -93,9 +92,11 @@ func (ds *DataSource) HTTPClientOptions() sdkhttpclient.Options {
|
|||||||
ExpectContinueTimeout: time.Duration(setting.DataProxyExpectContinueTimeout) * time.Second,
|
ExpectContinueTimeout: time.Duration(setting.DataProxyExpectContinueTimeout) * time.Second,
|
||||||
MaxConnsPerHost: setting.DataProxyMaxConnsPerHost,
|
MaxConnsPerHost: setting.DataProxyMaxConnsPerHost,
|
||||||
MaxIdleConns: setting.DataProxyMaxIdleConns,
|
MaxIdleConns: setting.DataProxyMaxIdleConns,
|
||||||
MaxIdleConnsPerHost: setting.DataProxyMaxIdleConnsPerHost,
|
MaxIdleConnsPerHost: setting.DataProxyMaxIdleConns,
|
||||||
IdleConnTimeout: time.Duration(setting.DataProxyIdleConnTimeout) * time.Second,
|
IdleConnTimeout: time.Duration(setting.DataProxyIdleConnTimeout) * time.Second,
|
||||||
},
|
}
|
||||||
|
opts := sdkhttpclient.Options{
|
||||||
|
Timeouts: timeouts,
|
||||||
Headers: getCustomHeaders(ds.JsonData, ds.DecryptedValues()),
|
Headers: getCustomHeaders(ds.JsonData, ds.DecryptedValues()),
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"datasource_name": ds.Name,
|
"datasource_name": ds.Name,
|
||||||
|
@ -850,11 +850,15 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
|||||||
DataProxyTLSHandshakeTimeout = dataproxy.Key("tls_handshake_timeout_seconds").MustInt(10)
|
DataProxyTLSHandshakeTimeout = dataproxy.Key("tls_handshake_timeout_seconds").MustInt(10)
|
||||||
DataProxyExpectContinueTimeout = dataproxy.Key("expect_continue_timeout_seconds").MustInt(1)
|
DataProxyExpectContinueTimeout = dataproxy.Key("expect_continue_timeout_seconds").MustInt(1)
|
||||||
DataProxyMaxConnsPerHost = dataproxy.Key("max_conns_per_host").MustInt(0)
|
DataProxyMaxConnsPerHost = dataproxy.Key("max_conns_per_host").MustInt(0)
|
||||||
DataProxyMaxIdleConns = dataproxy.Key("max_idle_connections").MustInt(100)
|
DataProxyMaxIdleConns = dataproxy.Key("max_idle_connections").MustInt()
|
||||||
DataProxyMaxIdleConnsPerHost = dataproxy.Key("max_idle_connections_per_host").MustInt(2)
|
|
||||||
DataProxyIdleConnTimeout = dataproxy.Key("idle_conn_timeout_seconds").MustInt(90)
|
DataProxyIdleConnTimeout = dataproxy.Key("idle_conn_timeout_seconds").MustInt(90)
|
||||||
cfg.SendUserHeader = dataproxy.Key("send_user_header").MustBool(false)
|
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 {
|
if err := readSecuritySettings(iniFile, cfg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user