Skip to main content
As your automation needs grow, n8n can scale horizontally to handle thousands of concurrent workflow executions. This guide covers queue mode architecture, worker configuration, and scaling strategies.

Understanding Queue Mode

Queue mode transforms n8n from a single-process application into a distributed system where workflow executions are processed by dedicated worker processes.

Architecture Components

Main Process

  • Serves web UI and API
  • Manages workflow definitions
  • Handles user authentication
  • Enqueues executions to Redis
  • Does NOT execute workflows

Worker Processes

  • Pull execution jobs from Redis queue
  • Execute workflow nodes
  • Save results to database
  • Can be scaled independently
  • Run on separate servers/containers

Redis (Message Broker)

  • Manages job queue (Bull)
  • Coordinates between main and workers
  • Handles job priorities and retries
  • Stores temporary execution state

PostgreSQL (Database)

  • Stores workflow definitions
  • Stores execution results
  • Manages credentials (encrypted)
  • Shared by all components
  • Required for queue mode

Execution Flow

Prerequisites

1

PostgreSQL Database

Queue mode requires PostgreSQL. SQLite is not supported.
2

Redis Server

Redis 6.0 or higher recommended.
3

Shared Encryption Key

Critical: All processes must use the same encryption key.
Common Mistakes:
  • Using different encryption keys across processes
  • Not persisting /home/node/.n8n on main process
  • Running workers without database access
  • Forgetting to configure Redis authentication

Basic Queue Mode Setup

Docker Compose Configuration

Starting in Queue Mode

Worker Configuration

Concurrency Settings

N8N_CONCURRENCY_PRODUCTION_LIMIT
number
default:"-1"
Maximum concurrent executions per worker. -1 means unlimited.
Recommendation: Start with 5-10 per worker, adjust based on:
  • Available CPU cores (1-2 executions per core)
  • Memory per worker (500MB-1GB per execution)
  • Execution complexity and duration

Worker Resources

Simple workflows with minimal data processing.

Worker Lock Settings

QUEUE_WORKER_LOCK_DURATION
number
default:"60000"
How long (ms) a worker holds a job lease.
QUEUE_WORKER_LOCK_RENEW_TIME
number
default:"10000"
How often (ms) to renew the job lease.
QUEUE_WORKER_STALLED_INTERVAL
number
default:"30000"
How often (ms) to check for stalled jobs.

Advanced Scaling

Queue Mode with Task Runners

Combine queue mode with external task runners for maximum isolation:

Multi-Main Setup (Enterprise)

Run multiple main processes for high availability:

Redis Configuration

Redis Cluster

For high availability Redis:

Redis with TLS

Redis Performance Tuning

Monitoring and Observability

Prometheus Metrics

Enable metrics on all processes:
Queue metrics are not supported in multi-main setup.

Key Metrics to Monitor

  • n8n_queue_jobs_waiting - Jobs waiting to be processed
  • n8n_queue_jobs_active - Currently executing jobs
  • n8n_queue_jobs_completed - Successfully completed jobs
  • n8n_queue_jobs_failed - Failed jobs
  • n8n_queue_jobs_delayed - Scheduled for future execution
  • process_cpu_user_seconds_total - CPU usage
  • process_resident_memory_bytes - Memory usage
  • n8n_workflow_executions_total - Execution count
  • n8n_workflow_execution_duration_seconds - Execution duration
  • Connection pool utilization
  • Query execution time
  • Active connections

Health Checks

Enable worker health endpoints:

Scaling Strategies

When to Scale

1

Monitor Queue Depth

Action: If consistently > 100, add workers.
2

Check Worker CPU

Action: If CPU > 80%, add more workers or reduce concurrency.
3

Measure Execution Latency

Track time from trigger to execution start.Action: If latency > 5 seconds, scale workers.
4

Review Failed Jobs

Action: Investigate failures, may indicate resource constraints.

Horizontal Scaling Formula

Vertical vs Horizontal Scaling

Performance Optimization

Database Optimization

Execution Optimization

Troubleshooting

Symptoms: Jobs waiting but workers idleCauses:
  1. Workers can’t connect to Redis
  2. Different encryption keys
  3. Workers crashed
Solutions:
Symptoms: Redis running out of memoryCauses:
  • Too many failed jobs accumulating
  • Large payloads in jobs
  • No eviction policy
Solutions:
Symptoms: Adding workers doesn’t increase throughputCauses:
  1. Database bottleneck
  2. Redis bottleneck
  3. Network limitations
  4. CPU constraints
Solutions:
  • Monitor database query times
  • Check Redis CPU usage
  • Profile slow workflows
  • Increase database connections
  • Consider database read replicas

Best Practices

Start Small

Begin with 2-3 workers and scale based on metrics, not guesses.

Monitor Everything

Track queue depth, worker CPU/memory, database performance, and execution latency.

Use Health Checks

Enable health checks on all components for automatic recovery.

Plan for Failures

Design workflows to be idempotent and handle retries gracefully.

Prune Execution Data

Regularly clean old execution data to maintain database performance.

Secure Redis

Always use authentication and TLS for Redis in production.

Next Steps

Configuration Reference

Complete list of environment variables

Docker Deployment

Docker Compose examples

Self-Hosting Overview

Understanding deployment options