fix(redis): configure maxmemory and eviction policy to prevent OOM
Some checks failed
CI / ruff (push) Successful in 11s
CI / pytest (push) Failing after 47m48s
CI / validate (push) Successful in 24s
CI / dependency-scanning (push) Successful in 31s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

Redis had no maxmemory set, causing the Prometheus alert expression
(used/max) to evaluate to +Inf. Set maxmemory to 100mb with allkeys-lru
eviction policy, and guard the alert expression against division by zero.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 17:57:38 +01:00
parent b5b73559b5
commit e61e02fb39
2 changed files with 2 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ services:
redis:
image: redis:7-alpine
restart: always
command: redis-server --maxmemory 100mb --maxmemory-policy allkeys-lru
ports:
- "6380:6379" # Use 6380 to avoid conflict with host Redis
mem_limit: 128m

View File

@@ -140,7 +140,7 @@ groups:
description: "Redis exporter cannot connect to Redis for 1 minute. Background tasks (emails, Celery) are not processing."
- alert: RedisHighMemoryUsage
expr: redis_memory_used_bytes / redis_memory_max_bytes * 100 > 80
expr: redis_memory_max_bytes > 0 and redis_memory_used_bytes / redis_memory_max_bytes * 100 > 80
for: 5m
labels:
severity: warning