From 9007d31bbf8bc5f43e7bf5b625f94531befc2f37 Mon Sep 17 00:00:00 2001 From: Adam Konrad Date: Tue, 26 Aug 2025 18:15:31 +0200 Subject: [PATCH 1/5] Optimize Redis configuration in `docker-compose.yml` by dynamically setting max memory using container's available memory. Removed unused `redis.conf`. --- docker-compose.yml | 9 ++++----- redis.conf | 27 --------------------------- 2 files changed, 4 insertions(+), 32 deletions(-) delete mode 100644 redis.conf diff --git a/docker-compose.yml b/docker-compose.yml index 2290a30142..cc2e3d4a15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -121,15 +121,14 @@ services: test: redis-cli ping | grep PONG volumes: - "sentry-redis:/data" - - type: bind - read_only: true - source: ./redis.conf - target: /usr/local/etc/redis/redis.conf ulimits: nofile: soft: 10032 hard: 10032 - command: ["redis-server", "/usr/local/etc/redis/redis.conf"] + # Configure Redis to use only 1/4 of the available memory inside the container + # We compute total memory from /proc/meminfo and pass it to redis-server as maxmemory + command: + ["CMD-SHELL", "MAXMEM=$(awk '/MemTotal/ {printf \'%d\', $2*1024/4}' /proc/meminfo); exec redis-server --maxmemory $MAXMEM --maxmemory-policy volatile-lru"] postgres: <<: *restart_policy # Using the same postgres version as Sentry dev for consistency purposes diff --git a/redis.conf b/redis.conf deleted file mode 100644 index 090b148b15..0000000000 --- a/redis.conf +++ /dev/null @@ -1,27 +0,0 @@ -# redis.conf - -# The 'maxmemory' directive controls the maximum amount of memory Redis is allowed to use. -# Setting 'maxmemory 0' means there is no limit on memory usage, allowing Redis to use as much -# memory as the operating system allows. This is suitable for environments where memory -# constraints are not a concern. -# -# Alternatively, you can specify a limit, such as 'maxmemory 15gb', to restrict Redis to -# using a maximum of 15 gigabytes of memory. -# -# Example: -# maxmemory 0 # Unlimited memory usage -# maxmemory 15gb # Limit memory usage to 15 GB - -maxmemory 0 - -# This setting determines how Redis evicts keys when it reaches the memory limit. -# `allkeys-lru` evicts the least recently used keys from all keys stored in Redis, -# allowing frequently accessed data to remain in memory while older data is removed. -# That said we use `volatile-lru` as Redis is used both as a cache and processing -# queue in self-hosted Sentry. -# > The volatile-lru and volatile-random policies are mainly useful when you want to -# > use a single Redis instance for both caching and for a set of persistent keys. -# > However, you should consider running two separate Redis instances in a case like -# > this, if possible. - -maxmemory-policy volatile-lru From 5333261f0eec391fb943fbb51c9321789bfcf983 Mon Sep 17 00:00:00 2001 From: Adam Konrad Date: Tue, 26 Aug 2025 21:30:20 +0200 Subject: [PATCH 2/5] Refactor Redis command in `docker-compose.yml` for improved readability and maintainability. --- docker-compose.yml | 249 ++------------------------------------------- 1 file changed, 7 insertions(+), 242 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cc2e3d4a15..70b302ede1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +```yaml x-restart-policy: &restart_policy restart: unless-stopped x-pull-policy: &pull_policy @@ -128,7 +129,11 @@ services: # Configure Redis to use only 1/4 of the available memory inside the container # We compute total memory from /proc/meminfo and pass it to redis-server as maxmemory command: - ["CMD-SHELL", "MAXMEM=$(awk '/MemTotal/ {printf \'%d\', $2*1024/4}' /proc/meminfo); exec redis-server --maxmemory $MAXMEM --maxmemory-policy volatile-lru"] + - sh + - -c + - > + MAXMEM=$(awk '/MemTotal/ {printf "%d", $2*1024/4}' /proc/meminfo); + exec redis-server --maxmemory $$MAXMEM --maxmemory-policy volatile-lru postgres: <<: *restart_policy # Using the same postgres version as Sentry dev for consistency purposes @@ -567,244 +572,4 @@ services: - feature-complete process-spans: <<: *sentry_defaults - command: run consumer --no-strict-offset-reset process-spans --consumer-group process-spans --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - process-segments: - <<: *sentry_defaults - command: run consumer --no-strict-offset-reset process-segments --consumer-group process-segments --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - monitors-clock-tick: - <<: *sentry_defaults - command: run consumer monitors-clock-tick --consumer-group monitors-clock-tick --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - monitors-clock-tasks: - <<: *sentry_defaults - command: run consumer monitors-clock-tasks --consumer-group monitors-clock-tasks --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - uptime-results: - <<: *sentry_defaults - command: run consumer uptime-results --consumer-group uptime-results --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - post-process-forwarder-transactions: - <<: *sentry_defaults - command: run consumer --no-strict-offset-reset post-process-forwarder-transactions --consumer-group post-process-forwarder --synchronize-commit-log-topic=snuba-transactions-commit-log --synchronize-commit-group transactions_group --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - post-process-forwarder-issue-platform: - <<: *sentry_defaults - command: run consumer --no-strict-offset-reset post-process-forwarder-issue-platform --consumer-group post-process-forwarder --synchronize-commit-log-topic=snuba-generic-events-commit-log --synchronize-commit-group generic_events_group --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - subscription-consumer-transactions: - <<: *sentry_defaults - command: run consumer transactions-subscription-results --consumer-group query-subscription-consumer --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - subscription-consumer-eap-items: - <<: *sentry_defaults - command: run consumer subscription-results-eap-items --consumer-group subscription-results-eap-items --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - subscription-consumer-metrics: - <<: *sentry_defaults - command: run consumer metrics-subscription-results --consumer-group query-subscription-consumer --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - subscription-consumer-generic-metrics: - <<: *sentry_defaults - command: run consumer generic-metrics-subscription-results --consumer-group query-subscription-consumer --healthcheck-file-path /tmp/health.txt - healthcheck: - <<: *file_healthcheck_defaults - profiles: - - feature-complete - sentry-cleanup: - <<: *sentry_defaults - image: sentry-cleanup-self-hosted-local - build: - context: ./cron - args: - BASE_IMAGE: sentry-self-hosted-local - entrypoint: "/entrypoint.sh" - command: '"0 0 * * * gosu sentry sentry cleanup --days $SENTRY_EVENT_RETENTION_DAYS"' - nginx: - <<: *restart_policy - ports: - - "$SENTRY_BIND:80/tcp" - image: "nginx:1.29.1-alpine" - volumes: - - type: bind - read_only: true - source: ./nginx.conf - target: /etc/nginx/nginx.conf - - sentry-nginx-cache:/var/cache/nginx - - sentry-nginx-www:/var/www - healthcheck: - <<: *healthcheck_defaults - test: - - "CMD" - - "/usr/bin/curl" - - http://localhost - depends_on: - - web - - relay - relay: - <<: *restart_policy - image: "$RELAY_IMAGE" - volumes: - - type: bind - read_only: true - source: ./relay - target: /work/.relay - - type: bind - read_only: true - source: ./geoip - target: /geoip - depends_on: - kafka: - <<: *depends_on-healthy - redis: - <<: *depends_on-healthy - web: - <<: *depends_on-healthy - healthcheck: - <<: *healthcheck_defaults - test: ["CMD", "/bin/relay", "healthcheck"] - taskbroker: - <<: *restart_policy - image: "$TASKBROKER_IMAGE" - environment: - TASKBROKER_KAFKA_CLUSTER: "kafka:9092" - TASKBROKER_KAFKA_DEADLETTER_CLUSTER: "kafka:9092" - TASKBROKER_DB_PATH: "/opt/sqlite/taskbroker-activations.sqlite" - volumes: - - sentry-taskbroker:/opt/sqlite - depends_on: - kafka: - <<: *depends_on-healthy - taskscheduler: - <<: *sentry_defaults - command: run taskworker-scheduler - taskworker: - <<: *sentry_defaults - command: run taskworker --concurrency=4 --rpc-host=taskbroker:50051 - vroom: - <<: *restart_policy - image: "$VROOM_IMAGE" - environment: - SENTRY_KAFKA_BROKERS_PROFILING: "kafka:9092" - SENTRY_KAFKA_BROKERS_OCCURRENCES: "kafka:9092" - SENTRY_BUCKET_PROFILES: file:///var/vroom/sentry-profiles - SENTRY_SNUBA_HOST: "http://snuba-api:1218" - volumes: - - sentry-vroom:/var/vroom/sentry-profiles - healthcheck: - <<: *healthcheck_defaults - test: - - "CMD" - - "/bin/bash" - - "-c" - # Courtesy of https://unix.stackexchange.com/a/234089/108960 - - 'exec 3<>/dev/tcp/127.0.0.1/8085 && echo -e "GET /health HTTP/1.1\r\nhost: 127.0.0.1\r\n\r\n" >&3 && grep OK -s -m 1 <&3' - depends_on: - kafka: - <<: *depends_on-healthy - profiles: - - feature-complete - vroom-cleanup: - <<: [*restart_policy, *pull_policy] - image: vroom-cleanup-self-hosted-local - build: - context: ./cron - args: - BASE_IMAGE: "$VROOM_IMAGE" - entrypoint: "/entrypoint.sh" - environment: - # Leaving the value empty to just pass whatever is set - # on the host system (or in the .env file) - SENTRY_EVENT_RETENTION_DAYS: - command: '"0 0 * * * find /var/vroom/sentry-profiles -type f -mtime +$SENTRY_EVENT_RETENTION_DAYS -delete"' - volumes: - - sentry-vroom:/var/vroom/sentry-profiles - profiles: - - feature-complete - uptime-checker: - <<: *restart_policy - image: "$UPTIME_CHECKER_IMAGE" - command: run - environment: - UPTIME_CHECKER_RESULTS_KAFKA_CLUSTER: kafka:9092 - UPTIME_CHECKER_REDIS_HOST: redis://redis:6379 - # Set to `true` will allow uptime checks against private IP addresses - UPTIME_CHECKER_ALLOW_INTERNAL_IPS: "false" - # The number of times to retry failed checks before reporting them as failed - UPTIME_CHECKER_FAILURE_RETRIES: "1" - # DNS name servers to use when making checks in the http checker. - # Separated by commas. Leaving this unset will default to the systems dns - # resolver. - #UPTIME_CHECKER_HTTP_CHECKER_DNS_NAMESERVERS: "8.8.8.8,8.8.4.4" - depends_on: - kafka: - <<: *depends_on-healthy - redis: - <<: *depends_on-healthy - profiles: - - feature-complete - -volumes: - # These store application data that should persist across restarts. - sentry-data: - external: true - sentry-postgres: - external: true - sentry-redis: - external: true - sentry-kafka: - external: true - sentry-clickhouse: - external: true - sentry-symbolicator: - external: true - # This volume stores JS SDK assets and the data inside this volume should - # be cleaned periodically on upgrades. - sentry-nginx-www: - # This volume stores profiles and should be persisted. - # Not being external will still persist data across restarts. - # It won't persist if someone does a docker compose down -v. - sentry-vroom: - # This volume stores task data that is inflight - # It should persist across restarts. If this volume is - # deleted, up to ~2048 tasks will be lost. - sentry-taskbroker: - # These store ephemeral data that needn't persist across restarts. - # That said, volumes will be persisted across restarts until they are deleted. - sentry-secrets: - sentry-smtp: - sentry-nginx-cache: - sentry-kafka-log: - sentry-smtp-log: - sentry-clickhouse-log: + command: run consumer --no-strict-offset-reset process-spans --consumer-group process-spans --healthcheck-file-path /tmp/health. From e15c731d32b78adf7b5ecde38a972655507363c2 Mon Sep 17 00:00:00 2001 From: Adam Konrad Date: Tue, 26 Aug 2025 21:34:11 +0200 Subject: [PATCH 3/5] Remove redundant YAML code block delimiter in `docker-compose.yml`. --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 70b302ede1..efaa549f3f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,3 @@ -```yaml x-restart-policy: &restart_policy restart: unless-stopped x-pull-policy: &pull_policy From 8df1aea11c6481b4470ddda1cf3e2ea4fd18b566 Mon Sep 17 00:00:00 2001 From: Adam Konrad Date: Tue, 26 Aug 2025 21:38:22 +0200 Subject: [PATCH 4/5] fix --- docker-compose.yml | 242 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 241 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index efaa549f3f..066aa772d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -571,4 +571,244 @@ services: - feature-complete process-spans: <<: *sentry_defaults - command: run consumer --no-strict-offset-reset process-spans --consumer-group process-spans --healthcheck-file-path /tmp/health. + command: run consumer --no-strict-offset-reset process-spans --consumer-group process-spans --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + process-segments: + <<: *sentry_defaults + command: run consumer --no-strict-offset-reset process-segments --consumer-group process-segments --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + monitors-clock-tick: + <<: *sentry_defaults + command: run consumer monitors-clock-tick --consumer-group monitors-clock-tick --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + monitors-clock-tasks: + <<: *sentry_defaults + command: run consumer monitors-clock-tasks --consumer-group monitors-clock-tasks --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + uptime-results: + <<: *sentry_defaults + command: run consumer uptime-results --consumer-group uptime-results --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + post-process-forwarder-transactions: + <<: *sentry_defaults + command: run consumer --no-strict-offset-reset post-process-forwarder-transactions --consumer-group post-process-forwarder --synchronize-commit-log-topic=snuba-transactions-commit-log --synchronize-commit-group transactions_group --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + post-process-forwarder-issue-platform: + <<: *sentry_defaults + command: run consumer --no-strict-offset-reset post-process-forwarder-issue-platform --consumer-group post-process-forwarder --synchronize-commit-log-topic=snuba-generic-events-commit-log --synchronize-commit-group generic_events_group --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + subscription-consumer-transactions: + <<: *sentry_defaults + command: run consumer transactions-subscription-results --consumer-group query-subscription-consumer --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + subscription-consumer-eap-items: + <<: *sentry_defaults + command: run consumer subscription-results-eap-items --consumer-group subscription-results-eap-items --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + subscription-consumer-metrics: + <<: *sentry_defaults + command: run consumer metrics-subscription-results --consumer-group query-subscription-consumer --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + subscription-consumer-generic-metrics: + <<: *sentry_defaults + command: run consumer generic-metrics-subscription-results --consumer-group query-subscription-consumer --healthcheck-file-path /tmp/health.txt + healthcheck: + <<: *file_healthcheck_defaults + profiles: + - feature-complete + sentry-cleanup: + <<: *sentry_defaults + image: sentry-cleanup-self-hosted-local + build: + context: ./cron + args: + BASE_IMAGE: sentry-self-hosted-local + entrypoint: "/entrypoint.sh" + command: '"0 0 * * * gosu sentry sentry cleanup --days $SENTRY_EVENT_RETENTION_DAYS"' + nginx: + <<: *restart_policy + ports: + - "$SENTRY_BIND:80/tcp" + image: "nginx:1.29.1-alpine" + volumes: + - type: bind + read_only: true + source: ./nginx.conf + target: /etc/nginx/nginx.conf + - sentry-nginx-cache:/var/cache/nginx + - sentry-nginx-www:/var/www + healthcheck: + <<: *healthcheck_defaults + test: + - "CMD" + - "/usr/bin/curl" + - http://localhost + depends_on: + - web + - relay + relay: + <<: *restart_policy + image: "$RELAY_IMAGE" + volumes: + - type: bind + read_only: true + source: ./relay + target: /work/.relay + - type: bind + read_only: true + source: ./geoip + target: /geoip + depends_on: + kafka: + <<: *depends_on-healthy + redis: + <<: *depends_on-healthy + web: + <<: *depends_on-healthy + healthcheck: + <<: *healthcheck_defaults + test: ["CMD", "/bin/relay", "healthcheck"] + taskbroker: + <<: *restart_policy + image: "$TASKBROKER_IMAGE" + environment: + TASKBROKER_KAFKA_CLUSTER: "kafka:9092" + TASKBROKER_KAFKA_DEADLETTER_CLUSTER: "kafka:9092" + TASKBROKER_DB_PATH: "/opt/sqlite/taskbroker-activations.sqlite" + volumes: + - sentry-taskbroker:/opt/sqlite + depends_on: + kafka: + <<: *depends_on-healthy + taskscheduler: + <<: *sentry_defaults + command: run taskworker-scheduler + taskworker: + <<: *sentry_defaults + command: run taskworker --concurrency=4 --rpc-host=taskbroker:50051 + vroom: + <<: *restart_policy + image: "$VROOM_IMAGE" + environment: + SENTRY_KAFKA_BROKERS_PROFILING: "kafka:9092" + SENTRY_KAFKA_BROKERS_OCCURRENCES: "kafka:9092" + SENTRY_BUCKET_PROFILES: file:///var/vroom/sentry-profiles + SENTRY_SNUBA_HOST: "http://snuba-api:1218" + volumes: + - sentry-vroom:/var/vroom/sentry-profiles + healthcheck: + <<: *healthcheck_defaults + test: + - "CMD" + - "/bin/bash" + - "-c" + # Courtesy of https://unix.stackexchange.com/a/234089/108960 + - 'exec 3<>/dev/tcp/127.0.0.1/8085 && echo -e "GET /health HTTP/1.1\r\nhost: 127.0.0.1\r\n\r\n" >&3 && grep OK -s -m 1 <&3' + depends_on: + kafka: + <<: *depends_on-healthy + profiles: + - feature-complete + vroom-cleanup: + <<: [*restart_policy, *pull_policy] + image: vroom-cleanup-self-hosted-local + build: + context: ./cron + args: + BASE_IMAGE: "$VROOM_IMAGE" + entrypoint: "/entrypoint.sh" + environment: + # Leaving the value empty to just pass whatever is set + # on the host system (or in the .env file) + SENTRY_EVENT_RETENTION_DAYS: + command: '"0 0 * * * find /var/vroom/sentry-profiles -type f -mtime +$SENTRY_EVENT_RETENTION_DAYS -delete"' + volumes: + - sentry-vroom:/var/vroom/sentry-profiles + profiles: + - feature-complete + uptime-checker: + <<: *restart_policy + image: "$UPTIME_CHECKER_IMAGE" + command: run + environment: + UPTIME_CHECKER_RESULTS_KAFKA_CLUSTER: kafka:9092 + UPTIME_CHECKER_REDIS_HOST: redis://redis:6379 + # Set to `true` will allow uptime checks against private IP addresses + UPTIME_CHECKER_ALLOW_INTERNAL_IPS: "false" + # The number of times to retry failed checks before reporting them as failed + UPTIME_CHECKER_FAILURE_RETRIES: "1" + # DNS name servers to use when making checks in the http checker. + # Separated by commas. Leaving this unset will default to the systems dns + # resolver. + #UPTIME_CHECKER_HTTP_CHECKER_DNS_NAMESERVERS: "8.8.8.8,8.8.4.4" + depends_on: + kafka: + <<: *depends_on-healthy + redis: + <<: *depends_on-healthy + profiles: + - feature-complete + +volumes: + # These store application data that should persist across restarts. + sentry-data: + external: true + sentry-postgres: + external: true + sentry-redis: + external: true + sentry-kafka: + external: true + sentry-clickhouse: + external: true + sentry-symbolicator: + external: true + # This volume stores JS SDK assets and the data inside this volume should + # be cleaned periodically on upgrades. + sentry-nginx-www: + # This volume stores profiles and should be persisted. + # Not being external will still persist data across restarts. + # It won't persist if someone does a docker compose down -v. + sentry-vroom: + # This volume stores task data that is inflight + # It should persist across restarts. If this volume is + # deleted, up to ~2048 tasks will be lost. + sentry-taskbroker: + # These store ephemeral data that needn't persist across restarts. + # That said, volumes will be persisted across restarts until they are deleted. + sentry-secrets: + sentry-smtp: + sentry-nginx-cache: + sentry-kafka-log: + sentry-smtp-log: + sentry-clickhouse-log: From 8ef00ee4e9b35d368d0956d1b2f293a3fa974944 Mon Sep 17 00:00:00 2001 From: Adam Konrad Date: Sat, 6 Sep 2025 21:40:21 -0500 Subject: [PATCH 5/5] limit memory in the redis config --- docker-compose.yml | 13 +++++-------- redis.conf | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 redis.conf diff --git a/docker-compose.yml b/docker-compose.yml index 066aa772d4..2290a30142 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -121,18 +121,15 @@ services: test: redis-cli ping | grep PONG volumes: - "sentry-redis:/data" + - type: bind + read_only: true + source: ./redis.conf + target: /usr/local/etc/redis/redis.conf ulimits: nofile: soft: 10032 hard: 10032 - # Configure Redis to use only 1/4 of the available memory inside the container - # We compute total memory from /proc/meminfo and pass it to redis-server as maxmemory - command: - - sh - - -c - - > - MAXMEM=$(awk '/MemTotal/ {printf "%d", $2*1024/4}' /proc/meminfo); - exec redis-server --maxmemory $$MAXMEM --maxmemory-policy volatile-lru + command: ["redis-server", "/usr/local/etc/redis/redis.conf"] postgres: <<: *restart_policy # Using the same postgres version as Sentry dev for consistency purposes diff --git a/redis.conf b/redis.conf new file mode 100644 index 0000000000..4168573c3e --- /dev/null +++ b/redis.conf @@ -0,0 +1,27 @@ +# redis.conf + +# The 'maxmemory' directive controls the maximum amount of memory Redis is allowed to use. +# Setting 'maxmemory 0' means there is no limit on memory usage, allowing Redis to use as much +# memory as the operating system allows. This is suitable for environments where memory +# constraints are not a concern. +# +# Alternatively, you can specify a limit, such as 'maxmemory 15gb', to restrict Redis to +# using a maximum of 15 gigabytes of memory. +# +# Example: +# maxmemory 0 # Unlimited memory usage +# maxmemory 15gb # Limit memory usage to 15 GB + +maxmemory 2gb + +# This setting determines how Redis evicts keys when it reaches the memory limit. +# `allkeys-lru` evicts the least recently used keys from all keys stored in Redis, +# allowing frequently accessed data to remain in memory while older data is removed. +# That said we use `volatile-lru` as Redis is used both as a cache and processing +# queue in self-hosted Sentry. +# > The volatile-lru and volatile-random policies are mainly useful when you want to +# > use a single Redis instance for both caching and for a set of persistent keys. +# > However, you should consider running two separate Redis instances in a case like +# > this, if possible. + +maxmemory-policy volatile-lru