By default, n8n runs in Own Mode. In this single-process mode, the main server handles the web UI, cron schedules, webhook listeners, and the actual execution of workflow nodes. As your throughput scales past tens of thousands of daily executions, a single process becomes a bottleneck. To scale horizontally, you must shift to Queue Mode.

1. Architecture of Queue Mode

In Queue Mode, n8n separates responsibilities across dedicated service blocks:

  • Main Instance: Runs the editor interface, handles API routes, manages schedules, and routes data.
  • Webhook Instances: Dedicated nodes that only listen for incoming webhook calls. They immediately offload the execution payload to a message queue and return a HTTP 200 response, preventing webhook timeouts.
  • Redis: Serves as the message broker, storing the execution queue.
  • Workers: Independent worker processes that subscribe to the Redis queue, execute the workflows, and save outcomes back to the database.

2. Configuring Redis and Environment Variables

To enable Queue Mode, you must set specific environment variables across your docker-compose containers:

# Enable Queue Mode
EXECUTIONS_MODE=queue

# Redis Connection Details
QUEUE_BULL_REDIS_HOST=redis
QUEUE_BULL_REDIS_PORT=6379
QUEUE_BULL_REDIS_PASSWORD=my_secure_redis_password

3. Database Optimization

Scaling CPU executors using workers is useless if your database locks up. When running in Queue Mode, SQLite is no longer supported because it cannot handle concurrent writes from multiple processes. You **must** switch to PostgreSQL:

DB_TYPE=postgresdb
DB_POSTGRES_HOST=postgres-db
DB_POSTGRES_PORT=5432
DB_POSTGRES_DATABASE=n8n
DB_POSTGRES_USER=n8n_user
DB_POSTGRES_PASSWORD=secure_postgres_pass

4. Handling High Execution Data Pruning

A high-volume n8n setup will fill up database tables rapidly. If you run 50,000 tasks daily, storing all node outputs can consume gigabytes of storage weekly. Set up data pruning to delete older executions automatically:

EXECUTIONS_DATA_PRUNE=true
EXECUTIONS_DATA_MAX_AGE=168 # Keep logs for 7 days (168 hours)
EXECUTIONS_DATA_PRUNE_TIMEOUT=3600

⚠️ Important: When scaling workers, verify that the shared folder mapping (for downloading or writing local files) is linked using a network file system (like NFS, AWS EFS, or Docker Shared Volumes) so that all worker processes can access the same files.