Skip to content

Use 2 Redis instances in Server image, redis-cache & redis-store

Warren Gifford requested to merge server_double_redis into master

Created by: mrnugget

This fixes #5015 (closed) by changing the Server image configuration to launch two Redis instances, one to be used as a cache and one as a store.

The cache instance runs on port 6380 (unused according to Wikipedia) and has maxmemory-policy allkeys-lru, which allows us to get rid of TTLs on the cache keys (which I want to do as a separate follow-up PR).

After looking at the usage of Redis on my local Sourcegraph instance, I decided to give the cache instance 800mb of memory and the store instance 200mb (1GB was the maxmemory value used before). If someone has better suggestions for this ratio, let me know.

I built and ran the server image locally and tested that both Redis instances get used by docker execing into the Server image and running redis-cli -p <port> MONITOR two times. See:

double_redis


FINAL SUMMARY:

  • This adds a new Redis instance to the Docker server image, redis-cache, that uses allkeys-lru eviction policy.
  • The rcache package now solely uses this redis-cache instance
  • Existing non-cache data in Redis is migrated to the non-cache Redis instance, redis-store.
  • Existing cache data, prefixed with the previous rcacheDataVersion of v1, will be deleted in the background when frontend boots up — this happens for all deployments of Sourcegraph.
  • A warning message is printed when Sourcegraph boots up and detects that the configured redis-cache instance doesn't use an allkeys-lru eviction policy — this happens for all deployments of Sourcegraph.

Merge request reports

Loading