Skip to content

Commit bfb5e61

Browse files
yeya24bwplotka
authored andcommitted
Add default value to query frontend memcached config (thanos-io#3398)
* 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> Signed-off-by: Oghenebrume50 <raphlbrume@gmail.com>
1 parent 9628990 commit bfb5e61

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
2424
- [#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`.
2525
- [#3381](https://github.com/thanos-io/thanos/pull/3381) Querier UI: Add ability to enable or disable metric autocomplete functionality.
2626
- [#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
27+
- [#3398](https://github.com/thanos-io/thanos/pull/3398) Query Frontend: Add default config for query frontend memcached config.
2728
- [#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.
2829

2930
### Fixed

docs/components/query-frontend.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ config:
8989

9090
Other cache configuration parameters, you can refer to [memcached-index-cache]( https://thanos.io/tip/components/store.md/#memcached-index-cache).
9191

92+
The default memcached config is:
93+
94+
```yaml
95+
type: MEMCACHED
96+
config:
97+
addresses: [your-memcached-addresses]
98+
timeout: 500ms
99+
max_idle_connections: 100
100+
max_async_concurrency: 10
101+
max_async_buffer_size: 10000
102+
max_get_multi_concurrency: 100
103+
max_get_multi_batch_size: 0
104+
dns_provider_update_interval: 10s
105+
expiration: 24h
106+
```
92107

93108
### Slow Query Log
94109

pkg/queryfrontend/config.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ const (
2727
MEMCACHED ResponseCacheProvider = "MEMCACHED"
2828
)
2929

30+
var (
31+
defaultMemcachedConfig = MemcachedResponseCacheConfig{
32+
Memcached: cacheutil.MemcachedClientConfig{
33+
Timeout: 500 * time.Millisecond,
34+
MaxIdleConnections: 100,
35+
MaxAsyncConcurrency: 10,
36+
MaxAsyncBufferSize: 10000,
37+
MaxGetMultiConcurrency: 100,
38+
MaxGetMultiBatchSize: 0,
39+
DNSProviderUpdateInterval: 10 * time.Second,
40+
},
41+
Expiration: 24 * time.Hour,
42+
}
43+
)
44+
3045
// InMemoryResponseCacheConfig holds the configs for the in-memory cache provider.
3146
type InMemoryResponseCacheConfig struct {
3247
// MaxSize represents overall maximum number of bytes cache can contain.
@@ -79,7 +94,7 @@ func NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Con
7994
},
8095
}, nil
8196
case string(MEMCACHED):
82-
var config MemcachedResponseCacheConfig
97+
config := defaultMemcachedConfig
8398
if err := yaml.UnmarshalStrict(backendConfig, &config); err != nil {
8499
return nil, err
85100
}
@@ -98,6 +113,11 @@ func NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Con
98113
config.Memcached.DNSProviderUpdateInterval = 10 * time.Second
99114
}
100115

116+
if config.Memcached.MaxAsyncConcurrency <= 0 {
117+
level.Warn(logger).Log("msg", "memcached max async concurrency must be positive, defaulting to 10")
118+
config.Memcached.MaxAsyncConcurrency = 10
119+
}
120+
101121
return &cortexcache.Config{
102122
Memcache: cortexcache.MemcachedConfig{
103123
Expiration: config.Expiration,

0 commit comments

Comments
 (0)