diff --git a/CHANGELOG.md b/CHANGELOG.md index 42ce5d241f..241ed42355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#3378](https://github.com/thanos-io/thanos/pull/3378) Ruler: added the ability to send queries via the HTTP method POST. Helps when alerting/recording rules are extra long because it encodes the actual parameters inside of the body instead of the URI. Thanos Ruler now uses POST by default unless `--query.http-method` is set `GET`. - [#3381](https://github.com/thanos-io/thanos/pull/3381) Querier UI: Add ability to enable or disable metric autocomplete functionality. - [#2979](https://github.com/thanos-io/thanos/pull/2979) Replicator: Add the ability to replicate blocks within a time frame by passing --min-time and --max-time +- [#3398](https://github.com/thanos-io/thanos/pull/3398) Query Frontend: Add default config for query frontend memcached config. - [#3277](https://github.com/thanos-io/thanos/pull/3277) Thanos Query: Introduce dynamic lookback interval. This allows queries with large step to make use of downsampled data. ### Fixed diff --git a/docs/components/query-frontend.md b/docs/components/query-frontend.md index 6c2e108080..4446999dd8 100644 --- a/docs/components/query-frontend.md +++ b/docs/components/query-frontend.md @@ -89,6 +89,21 @@ config: Other cache configuration parameters, you can refer to [memcached-index-cache]( https://thanos.io/tip/components/store.md/#memcached-index-cache). +The default memcached config is: + +```yaml +type: MEMCACHED +config: + addresses: [your-memcached-addresses] + timeout: 500ms + max_idle_connections: 100 + max_async_concurrency: 10 + max_async_buffer_size: 10000 + max_get_multi_concurrency: 100 + max_get_multi_batch_size: 0 + dns_provider_update_interval: 10s + expiration: 24h +``` ### Slow Query Log diff --git a/pkg/queryfrontend/config.go b/pkg/queryfrontend/config.go index 6f0550b46d..19db2c8b4c 100644 --- a/pkg/queryfrontend/config.go +++ b/pkg/queryfrontend/config.go @@ -27,6 +27,21 @@ const ( MEMCACHED ResponseCacheProvider = "MEMCACHED" ) +var ( + defaultMemcachedConfig = MemcachedResponseCacheConfig{ + Memcached: cacheutil.MemcachedClientConfig{ + Timeout: 500 * time.Millisecond, + MaxIdleConnections: 100, + MaxAsyncConcurrency: 10, + MaxAsyncBufferSize: 10000, + MaxGetMultiConcurrency: 100, + MaxGetMultiBatchSize: 0, + DNSProviderUpdateInterval: 10 * time.Second, + }, + Expiration: 24 * time.Hour, + } +) + // InMemoryResponseCacheConfig holds the configs for the in-memory cache provider. type InMemoryResponseCacheConfig struct { // MaxSize represents overall maximum number of bytes cache can contain. @@ -79,7 +94,7 @@ func NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Con }, }, nil case string(MEMCACHED): - var config MemcachedResponseCacheConfig + config := defaultMemcachedConfig if err := yaml.UnmarshalStrict(backendConfig, &config); err != nil { return nil, err } @@ -98,6 +113,11 @@ func NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Con config.Memcached.DNSProviderUpdateInterval = 10 * time.Second } + if config.Memcached.MaxAsyncConcurrency <= 0 { + level.Warn(logger).Log("msg", "memcached max async concurrency must be positive, defaulting to 10") + config.Memcached.MaxAsyncConcurrency = 10 + } + return &cortexcache.Config{ Memcache: cortexcache.MemcachedConfig{ Expiration: config.Expiration,