Use 2 Redis instances in Server image, redis-cache & redis-store
Created by: mrnugget
This fixes #5015 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 exec
ing into the Server image and running redis-cli -p <port> MONITOR
two times. See:
FINAL SUMMARY:
- This adds a new Redis instance to the Docker server image,
redis-cache
, that usesallkeys-lru
eviction policy. - The
rcache
package now solely uses thisredis-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
ofv1
, 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 anallkeys-lru
eviction policy — this happens for all deployments of Sourcegraph.