Learn how to efficiently scale n8n by enabling queue mode and deploying multiple workers using Docker. Queue mode separates the main n8n instance from workers, allowing workflows to process in parallel without being blocked by long tasks.
Prerequisites for Setting Up n8n Queue Mode
Before beginning the setup for n8n queue mode, make sure you meet the following requirements:
prerequisites
- A server or VPS with Docker installed.
- Basic familiarity with n8n workflow configurations.
- Installation of Redis as the queue manager.
- Hosting from providers like Hostinger or equivalent services.
Steps to Set Up n8n Queue Mode
Follow these steps to enable queue mode and scale n8n with multiple workers:
steps
Prepare Your Server Environment: Ensure
dockeranddocker-composeare installed on your server. Install Redis for queue management:bashsudo apt-get update sudo apt-get install redis sudo systemctl start redisInstall n8n and Configure the Main Instance: Create a
docker-compose.ymlfile for the main n8n instance. Configure Redis and database connections:yamlversion: '3' services: n8n: image: n8nio/n8n ports: - 5678:5678 environment: - EXECUTIONS_PROCESS=main - QUEUE_MODE=true - REDIS_HOST=redis - DB_TYPE=postgresdb # Adapt if using a different DB restart: always redis: image: redis:alpine restart: alwaysStart the services:
bashdocker-compose up -dLaunch Worker Instances: Add worker containers in the same
docker-compose.ymlto facilitate parallel execution:yamlworker-1: image: n8nio/n8n environment: - EXECUTIONS_PROCESS=queue - N8N_MODE=worker - REDIS_HOST=redis depends_on: - redis restart: always worker-2: image: n8nio/n8n environment: - EXECUTIONS_PROCESS=queue - N8N_MODE=worker - REDIS_HOST=redis depends_on: - redis restart: alwaysRestart Docker to apply changes:
bashdocker-compose down docker-compose up -dVerify Worker Activity: Access your Redis instance to verify queued jobs:
bashredis-cli KEYS *Run test workflows to ensure proper execution and monitor resource usage with
docker stats.
Common Mistakes and Troubleshooting
When configuring n8n queue mode, avoid the following:
Verifying the Setup
You can validate your n8n queue mode setup by testing with actual workflows.
steps
Run a Workflow with Large Data: Configure a workflow to process large numbers of items (e.g., 10,000 rows). Monitor the execution time.
Check Parallel Execution: Log into Redis and view active job queues:
bashredis-cli LRANGE bull:queue_name:active 0 -1Monitor Resource Utilization: Use the following command to inspect Docker container stats:
bashdocker statsConfirm that each worker is actively processing jobs.
Benefits of Scaling with Queue Mode
Switching to queue mode offers distinct advantages:
comparison
Default Single Process Mode
- Sequential task handling.
- Webhooks may be blocked during long workflow executions.
Queue Mode with Workers
- Allows parallel processing of tasks.
- Improves stability under high load.
- Enables flexible retry mechanisms for failures.
Making the Choice Between Hostinger and Other VPS Providers
Choosing Hosting Providers
- Choose Hostinger if you need simplified setup with ample documentation and support.
- Evaluate competitors for cost vs. resource availability.
- Ensure hosting plans support sufficient CPU and memory for your scaling needs.
FAQ
How does queue mode scale n8n processes?
Queue mode separates workflow orchestration (main instance) from task execution (workers). This allows tasks to be processed in parallel, improving throughput and scalability.
Can I use queue mode without Redis?
No, Redis is required to manage the job queue. It acts as the intermediary between the main n8n instance and worker nodes.
What hardware do I need for n8n queue mode?
A multi-core server is recommended. Allocate at least one CPU core per worker instance for optimal performance. For handling large datasets, ensure adequate memory is available as well.
Official reference: n8n documentation.