n8n queue mode with Redis
How to configure n8n in queue mode with Redis and separate workers to scale workflows with LLMs and high-concurrency webhooks in production.
In production, running n8n in queue mode prevents a slow workflow (a 30s LLM call, for example) from blocking the entire webhook queue.
Architecture
Webhook ──▶ n8n main (HTTP) ──▶ Redis (queue) ──▶ n8n worker(s) ──▶ Postgres
main: receives the webhook, enqueues it and returns 200 immediatelyworker: pulls from the queue, executes and persists to PostgresRedis: queue broker (BullMQ under the hood)
Prerequisites
- Postgres 14+ (recommended: container or external service)
- Redis 7+
- VPS with 4+ vCPU and 8 GB of RAM
Minimal docker-compose.yml
services:
postgres:
image: postgres:16
environment:
POSTGRES_USER: n8n
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: n8n
volumes:
- pg_data:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7-alpine
restart: unless-stopped
n8n-main:
image: docker.n8n.io/n8nio/n8n
environment:
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_USER: n8n
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
DB_POSTGRESDB_DATABASE: n8n
N8N_HOST: n8n.exemplo.com
WEBHOOK_URL: https://n8n.exemplo.com/
N8N_PROTOCOL: https
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
ports:
- "5678:5678"
depends_on: [postgres, redis]
restart: unless-stopped
n8n-worker:
image: docker.n8n.io/n8nio/n8n
command: worker
environment:
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_USER: n8n
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
DB_POSTGRESDB_DATABASE: n8n
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
depends_on: [postgres, redis]
restart: unless-stopped
volumes:
pg_data:
Scale workers
For more throughput, scale only the workers:
docker compose up -d --scale n8n-worker=4
Each worker takes 1 job at a time by default. For light jobs (no LLM), raise N8N_CONCURRENCY=10 per worker.
How to tell it is working
Look for this log in the workers on startup:
n8n Task Broker is now accepting connections on port 5679
n8n worker is now ready
- version: 1.x.x
- concurrency: 10
And in main:
Editor is now accessible via:
https://n8n.exemplo.com/
Monitoring
We recommend exposing BullMQ metrics via /metrics (Prometheus) and charting them in Grafana:
- Active / waiting / completed jobs
- Average execution time per workflow
- Failures per hour
Next steps
Last updated: