-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow use of Redis for all caches #4371
Conversation
ea0aa80
to
8e15750
Compare
Note that I am purposefully not including updates to the Jsonnet or Helm chart as part of these changes (there's enough to review as-is). |
@@ -119,3 +125,17 @@ func newMemcachedIndexCache(cfg cache.MemcachedConfig, logger log.Logger, regist | |||
|
|||
return indexcache.NewTracingIndexCache(c, logger), nil | |||
} | |||
|
|||
func newRedisIndexCache(cfg cache.RedisClientConfig, logger log.Logger, registerer prometheus.Registerer) (indexcache.IndexCache, error) { | |||
client, err := cache.NewRedisClient(logger, "index-cache", cfg, prometheus.WrapRegistererWithPrefix("thanos_", registerer)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had a discussion to deprecate thanos_
metrics prefix. Should we just use cortex_
prefix for the new change in this PR? Applicable also for memcached client metrics prefix few lines above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather make the change to all cache metrics at the same time. It's the same amount of work if we support cortex_
for Redis metrics and thanos_
for Memcached vs using thanos_
for both now and cortex_
for both later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more specific, using thanos_
here now means Redis will work with our dashboards as currently written with no extra effort. Then, they can be migrated to use the cortex_
prefix at the same time as the Memcached backend also with no extra effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Nick. I think for now we should just aim for consistency (unfortunately...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good job, LGTM! I just left a couple of comments I would be glad if you could look at before merging. I would love to merge this PR asap, cause I want to add metadata cache support to compactor and I would love to do it on top of this. Thanks!
- Query-scheduler | ||
- `-query-scheduler.querier-forget-delay` | ||
- Max number of used instances (`-query-scheduler.max-used-instances`) | ||
- Store-gateway | ||
- `-blocks-storage.bucket-store.chunks-cache.fine-grained-chunks-caching-enabled` | ||
- Use of Redis cache backend (`-blocks-storage.bucket-store.chunks-cache.backend=redis`, `-blocks-storage.bucket-store.index-cache.backend=redis`, `-blocks-storage.bucket-store.metadata-cache.backend=redis`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] The metadata cache is used also by the querier.
cfg.Memcached.RegisterFlagsWithPrefix(f, prefix+"memcached.") | ||
cfg.InMemory.RegisterFlagsWithPrefix(prefix+"inmemory.", f) | ||
cfg.Memcached.RegisterFlagsWithPrefix(prefix+"memcached.", f) | ||
cfg.Redis.RegisterFlagsWithPrefix(prefix+"redis.", f) | ||
} | ||
|
||
// Validate the config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the IndexCacheConfig.Validate()
below to run the validation on BackendConfig.Validate()
instead of just BackendConfig.Memcached.Validate()
, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposing the errors here so I can write a test against the validation method: grafana/dskit#276
@@ -119,3 +125,17 @@ func newMemcachedIndexCache(cfg cache.MemcachedConfig, logger log.Logger, regist | |||
|
|||
return indexcache.NewTracingIndexCache(c, logger), nil | |||
} | |||
|
|||
func newRedisIndexCache(cfg cache.RedisClientConfig, logger log.Logger, registerer prometheus.Registerer) (indexcache.IndexCache, error) { | |||
client, err := cache.NewRedisClient(logger, "index-cache", cfg, prometheus.WrapRegistererWithPrefix("thanos_", registerer)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Nick. I think for now we should just aim for consistency (unfortunately...).
See grafana/mimir#4371 Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
…276) * Export Redis config validation errors so they can be tested against See grafana/mimir#4371 Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This change pulls in a version of dskit that supports using Redis implementations for the `cache.Cache` and `cache.RemoteCacheClient` interfaces. The query-frontend caching integration test now runs with both Memcached and Redis caches. Redis can also be enabled for the microservices docker compose environment. See #4236 Fixes #4341 Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
ba50778
to
07eff10
Compare
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
What this PR does
This change pulls in a version of dskit that supports using Redis implementations for the
cache.Cache
andcache.RemoteCacheClient
interfaces. The query-frontend caching integration test now runs with both Memcached and Redis caches. Redis can also be enabled for the microservices docker compose environment.Which issue(s) this PR fixes or relates to
See #4236
Fixes #4341
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]