Skip to content

Add support for running a second redis container

Matthias Käppler requested to merge 57-multi-redis-support into master

Overview

This allows us to split redis traffic based on clients, similar to what we do in production. A new service is added, redis-alt, which will be targeted by a redis store specified in CUSTOM_REDIS_ALT_STORE.

For now this means the feature is limited to separate out only a single client-server relationship, but that is likely good enough to test key space splitting.

Implementation

  • A new compose service redis-alt is added, which does not run by default
  • In order for clients to target this instance, one must set CUSTOM_REDIS_ALT_STORE=cache|shared_state... in gck.env
  • This will emit a matching config file redis.[var_value].yml which the Rails client will prioritize over the default resque.yml for any redis wrapper where the store name matches

Example

  1. Edit gck.env and set CUSTOM_REDIS_ALT_STORE=cache
  2. Run make up-redis-alt
  3. Run make down-web up-web

The web app should now target redis-alt for cache entries:

$ make redis-alt-console
...
redis-alt:6379> KEYS *
  1) "cache:gitlab:flipper/v1/feature/new_graphql_keyset_pagination"
  2) "cache:gitlab:root_ref:h5bp/html5-boilerplate:8"
  3) "cache:gitlab:flipper/v1/feature/sast_entry_points"
  4) "cache:gitlab:projects/count_service/1/4/forks_count"
  5) "cache:gitlab:projects/count_service/1/5/open_merge_requests_count"
...
173) "cache:gitlab:projects/count_service/1/1/project_open_public_issues_without_hidden_count"
174) "cache:gitlab:projects/count_service/1/1/open_merge_requests_count"
$ make redisconsole
...
redis:6379> KEYS *
1) "session:gitlab:2::65590c211b693a0bcb77bf075df5482552394de45ce7d7cc4987e5da578ed624"
2) "session:lookup:user:gitlab:1"
3) "session:user:gitlab:1:2::65590c211b693a0bcb77bf075df5482552394de45ce7d7cc4987e5da578ed624"
4) "cache:gitlab:flipper/v1/feature/request_apdex_counters"
5) "cache:gitlab:flipper/v1/feature/partition_pruning"
6) "cache:gitlab:flipper/v1/feature/active_record_transactions_tracking"
7) "gitlab:exclusive_lease:el:throttle:/home/git/gitlab/app/models/user.rb:94:1"
8) "cache:gitlab:flipper/v1/feature/new_customersdot_staging_url"

I'm not sure why there are still some cache entries in the main redis. Perhaps they persisted from previous runs?

Closes #57 (closed)

Edited by Matthias Käppler

Merge request reports