Overview
Nadoo AI uses Redis 7 as a multi-purpose in-memory data store. A single Redis instance serves several roles across the platform:| Role | Description |
|---|---|
| Celery Broker | Message broker for background task queuing (document processing, embeddings, cleanup) |
| Celery Result Backend | Stores task results and status for monitoring |
| WebSocket Pub/Sub | Enables horizontal scaling of real-time chat by broadcasting messages across backend workers |
| Permission Cache | Optional Redis-backed permission cache for multi-server / HA deployments |
| Celery Beat (RedBeat) | Distributed scheduler storage for periodic tasks via RedBeat |
Docker Configuration
The production Docker Compose includes a Redis service with AOF persistence enabled:Environment Variables
All Redis-related variables use theNADOO_ prefix:
| Variable | Default | Description |
|---|---|---|
NADOO_REDIS_HOST | localhost | Redis server hostname |
NADOO_REDIS_PORT | 6379 | Redis server port |
NADOO_REDIS_PASSWORD | null | Redis authentication password |
NADOO_REDIS_DB | 0 | Redis database number for general use |
NADOO_PERMISSION_CACHE_REDIS_ENABLED | false | Enable Redis-backed permission caching |
NADOO_PERMISSION_CACHE_REDIS_DB | 1 | Redis DB number for permission cache |
NADOO_PERMISSION_CACHE_TTL | 300 | Permission cache TTL in seconds |
NADOO_CELERY_BROKER_URL | (auto) | Override Celery broker URL. Auto-derived from Redis settings if not set. |
NADOO_CELERY_RESULT_BACKEND | (auto) | Override Celery result backend URL. Auto-derived from Redis settings if not set. |
How Redis Is Used
Celery Task Broker
Celery Task Broker
Redis serves as the message broker for Celery workers. When the backend enqueues a task (e.g., document ingestion), Redis stores the message until a worker picks it up.Key broker transport options configured in the application:The
visibility_timeout ensures that if a worker crashes mid-task, the message becomes visible again for another worker to pick up after 1 hour.WebSocket Pub/Sub
WebSocket Pub/Sub
Real-time chat uses Redis pub/sub for broadcasting messages across multiple backend processes. When a user sends a chat message, the response stream is published to a Redis channel so that every connected WebSocket client receives updates regardless of which backend worker handles the connection.This is essential for horizontal scaling with multiple Uvicorn workers or multiple backend containers.
Permission Cache
Permission Cache
For multi-server deployments, enable Redis-backed permission caching to avoid redundant database queries:This stores computed user permissions in Redis DB 1 with a 5-minute TTL. Single-server deployments can leave this disabled (the default) and use in-process caching instead.
RedBeat Scheduler
RedBeat Scheduler
Celery Beat uses RedBeat to store periodic task schedules in Redis. This allows user-defined scheduled jobs to persist across restarts without a separate database table.The RedBeat keys are stored with the prefix
nadoo:redbeat: and use a distributed lock at nadoo:redbeat:lock with a 25-second timeout.Persistence and Durability
Redis is configured with AOF (Append Only File) persistence:| Setting | Value | Meaning |
|---|---|---|
appendonly | yes | Every write operation is logged to an append-only file |
appendfsync | everysec | Fsync the AOF file once per second (good balance of durability and performance) |
redis_data (mounted at /data in the container).
Production Hardening
For production deployments, consider adding aredis.conf file with these settings:
NADOO_REDIS_PASSWORD accordingly:
Backup and Restore
Backup
Restore
Monitoring
Redis CLI
Redis Commander (Optional)
The production Docker Compose includes an optional Redis Commander web UI:http://localhost:38081.
Troubleshooting
Celery workers cannot connect to Redis
Celery workers cannot connect to Redis
Verify Redis is running and reachable from the worker container:If using a password, ensure
NADOO_REDIS_PASSWORD is set identically on all services (backend, celery, celery-beat).Redis memory usage keeps growing
Redis memory usage keeps growing
Set a Also verify that
maxmemory limit and eviction policy:result_expires is set in Celery config (default: 3600 seconds) so task results are cleaned up automatically.Tasks reappearing after completion
Tasks reappearing after completion
This is usually caused by a
visibility_timeout that is shorter than the task execution time. The Nadoo default is 3600 seconds (1 hour). If you have tasks that run longer, increase the timeout: