How to deploy worker n8n instances on n8n
Deploy worker n8n instances by configuring the main n8n instance as a queue mode setup with Redis, then launching separate worker containers that connect to the same database and Redis instance. Workers handle execution while the main instance manages the UI and workflow definitions.
Prerequisites
- n8n installed and configured
- Docker or Kubernetes environment
- Redis instance for queue management
- Basic understanding of microservices architecture
Step-by-Step Instructions
Configure Redis for Queue Management
N8N_EXECUTIONS_MODE=queue
QUEUE_BULL_REDIS_HOST=your-redis-host
QUEUE_BULL_REDIS_PORT=6379
QUEUE_BULL_REDIS_PASSWORD=your-redis-passwordConfigure Main n8n Instance for Queue Mode
N8N_EXECUTIONS_MODE=queue
EXECUTIONS_PROCESS=main
N8N_SKIP_WEBHOOK_DEREGISTRATION_SHUTDOWN=trueRestart your main n8n instance to apply the queue mode configuration.
Prepare Worker Configuration
N8N_EXECUTIONS_MODE=queue
EXECUTIONS_PROCESS=worker
DB_TYPE=your-database-type
DB_POSTGRESDB_HOST=your-db-host
DB_POSTGRESDB_DATABASE=your-n8n-databaseDeploy Worker Containers
docker run -d \
--name n8n-worker-1 \
-e N8N_EXECUTIONS_MODE=queue \
-e EXECUTIONS_PROCESS=worker \
-e QUEUE_BULL_REDIS_HOST=redis-host \
-e DB_POSTGRESDB_HOST=db-host \
n8nio/n8n:latestConfigure Worker Scaling
EXECUTIONS_PROCESS_MAX_CONCURRENT=10
QUEUE_BULL_REDIS_MAX_STALLEDCOUNT=1Monitor Redis queue metrics to determine optimal worker count and scaling policies.
Verify Worker Registration
docker logs n8n-worker-1Test Workflow Execution
Monitor and Maintain Workers
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5678/healthz || exit 1Common Issues & Troubleshooting
Workers not processing executions from queue
Verify Redis connection settings match between main instance and workers. Check that QUEUE_BULL_REDIS_HOST and credentials are identical across all instances.
Database connection errors in worker instances
Ensure workers have the same database configuration as the main instance. Verify DB_POSTGRESDB_HOST, DB_POSTGRESDB_DATABASE, and credentials are correctly set in worker environment variables.
Workflows stuck in 'running' status
Check worker logs for execution errors and verify EXECUTIONS_PROCESS_MAX_CONCURRENT is not too high. Restart stuck workers and monitor Redis queue for stalled jobs using QUEUE_BULL_REDIS_MAX_STALLEDCOUNT.
High memory usage in worker instances
Reduce EXECUTIONS_PROCESS_MAX_CONCURRENT value and implement worker restarts after processing a certain number of jobs. Consider scaling horizontally with more workers instead of increasing concurrent executions per worker.