From d30b7803833ff807431bbacde062e8ad0d0892a4 Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Tue, 8 Jun 2021 14:41:45 +0300 Subject: [PATCH] Add max_idle_connections_per_host to config (#35365) --- conf/defaults.ini | 9 ++++++--- conf/sample.ini | 7 +++++-- pkg/models/datasource_cache.go | 1 + pkg/setting/setting.go | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index b373dd30622..408f45b699d 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -69,7 +69,7 @@ socket = /tmp/grafana.sock # CDN Url cdn_url = -# Sets the maximum time in minutes before timing out read of an incoming request and closing idle connections. +# Sets the maximum time in minutes before timing out read of an incoming request and closing idle connections. # `0` means there is no timeout for reading the request. read_timeout = 0 @@ -158,6 +158,9 @@ expect_continue_timeout_seconds = 1 # 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 @@ -520,11 +523,11 @@ active_sync_enabled = true #################################### AWS ########################### [aws] -# Enter a comma-separated list of allowed AWS authentication providers. +# Enter a comma-separated list of allowed AWS authentication providers. # Options are: default (AWS SDK Default), keys (Access && secret key), credentials (Credentials field), ec2_iam_role (EC2 IAM Role) allowed_auth_providers = default,keys,credentials -# Allow AWS users to assume a role using temporary security credentials. +# Allow AWS users to assume a role using temporary security credentials. # If true, assume role will be enabled for all AWS authentication providers that are specified in aws_auth_providers assume_role_enabled = true diff --git a/conf/sample.ini b/conf/sample.ini index 57f376ecac0..7c12f4f86dd 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -164,6 +164,9 @@ # 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 @@ -510,11 +513,11 @@ #################################### AWS ########################### [aws] -# Enter a comma-separated list of allowed AWS authentication providers. +# Enter a comma-separated list of allowed AWS authentication providers. # Options are: default (AWS SDK Default), keys (Access && secret key), credentials (Credentials field), ec2_iam_role (EC2 IAM Role) ; allowed_auth_providers = default,keys,credentials -# Allow AWS users to assume a role using temporary security credentials. +# Allow AWS users to assume a role using temporary security credentials. # If true, assume role will be enabled for all AWS authentication providers that are specified in aws_auth_providers ; assume_role_enabled = true diff --git a/pkg/models/datasource_cache.go b/pkg/models/datasource_cache.go index c8412ecb9d2..c3ecec176d2 100644 --- a/pkg/models/datasource_cache.go +++ b/pkg/models/datasource_cache.go @@ -167,6 +167,7 @@ func (ds *DataSource) GetHttpTransport() (*dataSourceTransport, error) { TLSHandshakeTimeout: time.Duration(setting.DataProxyTLSHandshakeTimeout) * time.Second, ExpectContinueTimeout: time.Duration(setting.DataProxyExpectContinueTimeout) * time.Second, MaxIdleConns: setting.DataProxyMaxIdleConns, + MaxConnsPerHost: setting.DataProxyMaxIdleConnsPerHost, IdleConnTimeout: time.Duration(setting.DataProxyIdleConnTimeout) * time.Second, } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 577e16d993b..52a36e605e8 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -83,6 +83,7 @@ var ( DataProxyTLSHandshakeTimeout int DataProxyExpectContinueTimeout int DataProxyMaxIdleConns int + DataProxyMaxIdleConnsPerHost int DataProxyKeepAlive int DataProxyIdleConnTimeout int StaticRootPath string @@ -809,6 +810,7 @@ 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) DataProxyMaxIdleConns = dataproxy.Key("max_idle_connections").MustInt(100) + DataProxyMaxIdleConnsPerHost = dataproxy.Key("max_idle_connections_per_host").MustInt(2) DataProxyIdleConnTimeout = dataproxy.Key("idle_conn_timeout_seconds").MustInt(90) cfg.SendUserHeader = dataproxy.Key("send_user_header").MustBool(false)