Skip to content

N8N in queue mode

N8N’s queue mode is a distributed execution architecture in which workflows are delegated to separate processes (workers) through a Redis queue. It replaces the default mode where everything runs in a single process.

ComponentRoleInstance
MainWeb UI, API, workflow triggering1 (singleton)
WorkersActual workflow executionN (scalable)
RedisBull queue + Pub/Sub coordination1 (shared)
PostgreSQLWorkflow storage, credentials, history1 (shared)

Redis · Bull Queue

bull:jobs:active

bull:jobs:waiting

Pub/Sub · worker coordination

N8N Main · :5678

Web UI

REST API

Webhooks · triggers

Enqueue jobs → Redis

Worker 1 · replica

Worker 2 · replica

Worker N · replica


By default, N8N executes workflows in the same process as the web interface. Consequences:

SymptomCauseImpact
Slow UICPU monopolised by a workflowDegraded UX
Webhook timeoutsA long workflow blocks the responseBroken integrations
No parallelismSingle execution threadBottleneck
Crash propagationA memory error brings everything downService outage

This setup addresses four concrete needs:

  1. Long API calls — Workflows using Claude or AI can take 5–30 seconds per call. Without a queue, the UI would freeze.

  2. Parallelism — Several webhooks can land at the same time (GitHub commits, Telegram messages). Each worker processes a job independently.

  3. Batch tasks — Data imports or large synchronisations (Odoo ↔ N8N) run in the background without impacting the UI.

  4. Reliability — Failed jobs are retried automatically. A crashing worker does not affect the others.


services:
n8n:
image: n8n-custom:latest # Image bundling custom nodes
environment:
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=n8n-redis
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
depends_on:
- n8n-postgres
- n8n-redis
n8n-worker:
image: n8n-custom:latest
command: worker
environment:
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=n8n-redis
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
deploy:
replicas: 5
n8n-redis:
image: redis:7-alpine
volumes:
- n8n-redis-data:/data
n8n-postgres:
image: postgres:15
environment:
- POSTGRES_DB=n8n

The number of workers (5 in this configuration) is driven by two constraints:

ConstraintCalculationResult
Rule of thumb1 worker per vCPU + 1 buffer4 + 1 = 5 workers
Available RAM~400 MB per worker5 × 400 = 2 GB (n8n-stack budget)

N8N provides Data Tables to store structured data directly inside the instance. The current setup uses around twenty, organised by domain:

DomainMain tables
TelegramTelegram Authorized users, Telegram Banned Users, Telegram Pending Approvals
DockerDocker_image_policies, Docker_pending_updates, Docker_pending_upd_approvals
Notificationsnotification_routing, notification_history, pending_notifications, pending_deferred, escalation_tracking
Errorserror_dead_letter_queue, error_handling_config
Telemetryclaude_code_active_sessions, claude_code_sessions_v2
External syncOdoo_github_project_mapping, timetrackr_user_mapping, content_pipeline
Workflowsn8n_trigger_whitelist, n8n_pending_actions, n8n_datatable_metadata

N8N talks to the AI Stack over internal HTTP:

// HTTP Request to CLI Ollama (Codex by default)
{
"url": "http://cli-ollama:11434/api/generate",
"method": "POST",
"body": {
"model": "codex-yolo",
"prompt": "Analyse this message...",
"stream": false
}
}

AI use cases:

  • Intent detection — The Telegram Orchestrator uses CLI Ollama to route messages
  • MCP via gateway — Admin workflows through the whitelisted MCP tools (n8n_get_workflow, n8n_executions, etc.)
  • RAG — Semantic search in Qdrant to enrich answers
  • Error analysiserror-analyst profile consumed by the GEH AI Auto-Fix workflow
Fenêtre de terminal
# Check active workers
docker compose -f n8n-stack/docker-compose.yaml ps
# Logs of a specific worker
docker logs n8n-stack-n8n-worker-3 --tail 100
# Scale workers dynamically
docker compose -f n8n-stack/docker-compose.yaml up -d --scale n8n-worker=8
# Inspect the Redis queue
docker exec n8n-redis redis-cli LLEN bull:jobs:waiting

LimitImpactMitigation
Single Redis instanceSPOF for the queueRegular snapshots, fast rebuild
No prioritiesJobs are FIFOCritical workflows are not prioritised
Manual scalingNo autoscalingMonitoring + periodic adjustments

If load grows significantly:

  • Add workers up to the RAM ceiling
  • Move to a beefier VPS (vertical scaling)
  • Split Redis/PostgreSQL onto their own instances

If a single workflow hogs resources:

  • Create a dedicated queue for long workflows
  • Configure per-workflow concurrency limits
  • Use sub-workflows to break processing into stages

If reliability becomes critical:

  • Deploy Redis in Sentinel mode (HA)
  • Add a second N8N main instance in standby
  • Externalise to Redis Cloud or AWS ElastiCache

To anticipate problems, monitor through the Monitoring Stack:

MetricAlert thresholdAction
bull:jobs:waiting> 50 jobsAdd workers
Worker CPU> 80% sustainedOptimise workflows or scale
Failed executions> 5%Investigate the errors