Sourcegraph DocsSourcegraph Docs
Changelog↗
Theme
  1. Docs
  2. self-hosted
  3. external-services
  4. redis

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_ENDPOINT for cached data. Set maxmemory-policy allkeys-lru on this instance; the frontend logs a warning on startup if it is not set.
  • REDIS_STORE_ENDPOINT for persistent data, such as user sessions and locks. Set maxmemory-policy noeviction on 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-0
  • sourcegraph-frontend-internal
  • gitserver-0
  • searcher-0
  • worker
  • precise-code-intel-worker
  • syntactic-code-intel-worker

A service without them keeps connecting to the built-in redis-cache and redis-store containers.

  1. 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.
  2. Replace the example values of REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT with your Redis endpoints.
  3. 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

On this page

  1. Using your own Redis server

    1. Docker Compose
    1. Kubernetes

Edit this page on GitHub
View as Markdown