Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Running n8n in production: queue mode, workers, and the settings that keep it alive

Description and use

This story details configuring n8n in queue mode to improve reliability and scalability. The problem is solved by separating roles: the main instance handles webhooks and UI, while workers execute tasks from a Redis queue. Execution history pruning and database backup verification are also critical.

Problem

Self-hosted n8n experiences failure modes where the editor stops loading, webhooks time out, and workflows silently stop. This is typically caused by single-instance execution (where heavy tasks starve the UI) or an unbounded executions table that grows until Postgres becomes a bottleneck or the disk fills.

Outcome

The system is now resilient to heavy executions, webhooks remain responsive, and the database remains stable due to pruning. The architecture supports horizontal scaling by adding worker replicas without state loss.

Workflow

  • Configure the main instance with shared settings (DB, N8N_ENCRYPTION_KEY, EXECUTIONS_MODE=queue, QUEUE_BULL_REDIS_HOST, QUEUE_BULL_REDIS_PORT, QUEUE_BULL_REDIS_PASSWORD).
  • Set N8N_WEBHOOK_URL and OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=true on the main instance.
  • Start worker processes using 'n8n worker' with QUEUE_HEALTH_CHECK_ACTIVE=true.
  • Configure execution pruning with EXECUTIONS_DATA_PRUNE=true, EXECUTIONS_DATA_MAX_AGE=336, and EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000.
  • Set up a compressed nightly pg_dump backup to an S3-compatible bucket and verify restores.
  • Disable diagnostics (N8N_DIAGNOSTICS_ENABLED=false) and pin the n8n image version and digest.
  • Scale horizontally by adding more worker replicas as load increases.

Evidence

In queue mode, n8n splits into two roles: The main instance serves the editor UI, receives webhooks, and manages schedules — but executes nothing. When a workflow should run, it pushes a job onto a Redis queue (Bull). One or more workers pull jobs from the queue and execute them.

Source

EXECUTIONS_DATA_PRUNE=true EXECUTIONS_DATA_MAX_AGE=336 # keep 14 days EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000

Source

A backup you've never restored is a hope, not a backup.

Source

  • Record date: 2026-09-09T00:32:19.255Z