Using your own Redis server
Version requirements: We support any version starting from 6.2. Redis Cluster and Redis Sentinel are not supported.
Generally, there is no reason to do this as Sourcegraph only stores ephemeral cache and session data in Redis. However, if you want to use an external Redis server with Sourcegraph, you can follow the deployment specific guidance below.
Sourcegraph uses two Redis instances, configured with these environment variables:
REDIS_CACHE_ENDPOINTfor cached data. Setmaxmemory-policy allkeys-lruon this instance; the frontend logs a warning on startup if it is not set.REDIS_STORE_ENDPOINTfor persistent data, such as user sessions and locks. Setmaxmemory-policy noevictionon this instance.
Each value is either host:port, or a URL following the IANA specification for Redis URLs, such as redis://:mypassword@redis-store.example.com:6379/0. Use the rediss:// scheme for a TLS connection.
Docker Compose
Set both environment variables on every service that connects to Redis:
sourcegraph-frontend-0sourcegraph-frontend-internalgitserver-0searcher-0workerprecise-code-intel-workersyntactic-code-intel-worker
A service without them keeps connecting to the built-in redis-cache and redis-store containers.
- Copy the external Redis example into your
docker-compose.override.yaml. It sets the variables on these services and disables the built-in Redis containers. - Replace the example values of
REDIS_CACHE_ENDPOINTandREDIS_STORE_ENDPOINTwith your Redis endpoints. - Apply the change with
docker compose up -d --remove-orphans.
Kubernetes
Kubernetes without Helm
- See our documentation for Kubernetes here
- Related: How to Set a Password for Redis using a ConfigMap