Skip to content

Commit

Permalink
Add default value to query frontend memcached config (#3398)
Browse files Browse the repository at this point in the history
* add default value to query frontend memcached config

Signed-off-by: Ben Ye <yb532204897@gmail.com>

* add changelog

Signed-off-by: Ben Ye <yb532204897@gmail.com>

Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
  • Loading branch information
yeya24 and bwplotka authored Nov 9, 2020
1 parent 29726a8 commit 75c808a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions docs/components/query-frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 21 additions & 1 deletion pkg/queryfrontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand All @@ -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,
Expand Down

0 comments on commit 75c808a

Please sign in to comment.