This system provides dynamic scaling for n8n worker containers based on the length of your Redis queue. It eliminates the need for Kubernetes or heavy orchestration by using a lightweight script to monitor the queue and adjust container counts on the fly. Built on a Docker Compose foundation, the setup has been verified on an 8-core, 16GB VPS and is capable of managing hundreds of concurrent executions.
The architecture connects several key components: the primary n8n instance pushes jobs into a Redis queue, while a dedicated autoscaler and a Redis monitor track the queue's activity. Depending on the queue depth, the autoscaler adds or removes worker containers as needed. PostgreSQL serves as the persistent data store, and the main n8n instance is configured to communicate with an n8n webhook service.
Ensure that Docker and Docker Compose are installed on your system. If you are on Ubuntu, you can use the official convenience script; otherwise, Docker Desktop is recommended for local environments.
.env file. While the defaults are functional for testing, you should update passwords and security tokens for any production use.docker compose up -d..env file before going live.N8N_CONCURRENCY_PRODUCTION_LIMIT=10 in the docker-compose.yml file.N8N_QUEUE_BULL_GRACEFULSHUTDOWNTIMEOUT=300 and N8N_GRACEFUL_SHUTDOWN_TIMEOUT=300 (in seconds). These should be set to a duration longer than your longest-running workflow to prevent data loss during scaling events.| Variable | Description | Default |
|---|---|---|
MIN_REPLICAS |
Minimum number of active worker containers | 1 |
MAX_REPLICAS |
Maximum number of worker containers allowed | 5 |
SCALE_UP_QUEUE_THRESHOLD |
Queue length required to trigger a scale-up action | 5 |
SCALE_DOWN_QUEUE_THRESHOLD |
Queue length required to trigger a scale-down action | 2 |
POLLING_INTERVAL_SECONDS |
Frequency (in seconds) of queue depth checks | 30 |
COOLDOWN_PERIOD_SECONDS |
Minimum wait time between consecutive scaling actions | 180 |
QUEUE_NAME_PREFIX |
Prefix used for the Redis queue | bull |
QUEUE_NAME |
Name of the target Redis queue | jobs |
EXECUTIONS_MODE=queue
QUEUE_BULL_REDIS_HOST=redis
QUEUE_HEALTH_CHECK_ACTIVE=true
The autoscaler evaluates the Redis queue at every POLLING_INTERVAL_SECONDS.
Scaling Up: If the queue length exceeds the SCALE_UP_QUEUE_THRESHOLD and the worker count is currently below MAX_REPLICAS, the autoscaler launches additional workers.
Scaling Down: If the queue length drops below the SCALE_DOWN_QUEUE_THRESHOLD and the worker count is above MIN_REPLICAS, the autoscaler terminates excess containers.
A cooldown period is enforced after every scaling event to prevent "thrashing"—the rapid, unnecessary starting and stopping of containers due to minor fluctuations in the queue.
Monitoring. The system includes a dedicated Redis monitor service. You can track the health of all services via Docker health checks, and the autoscaler provides detailed activity logs for auditing.
Troubleshooting Tips
docker-compose logs [service_name]docker-compose exec redis redis-cli pingdocker-compose exec redis redis-cli LLEN bull:jobs:waitImportant Note on Webhook URLs: When configuring webhooks within this setup, use the Docker service name rather than localhost. For example: http://n8n-webhook:5678/webhook/[unique-id].
DeepSeek-OCR WebUI: Batch OCR with Markdown Tables and Visual Bounding Boxes
OpenAI’s New Open-Weight Models: gpt-oss-120b & 20b
Clueless: A Native AI Meeting Assistant for Mac with Live Transcription
Postiz Setup Guide: Schedule Smarter with This Open-Source AI Tool
SerenityOS Build Guide: A C++ Unix-Like System for x86, Arm, and RISC-V
QSV: Slice, Query, and Clean Massive CSV Files with High Performance
AI Peer Review Tool for Neuroscience: LLM-Driven Meta-Review Framework
Deepwiki MCP Server: Fetch and Convert Wiki Pages to Markdown
ALLinSSL: Automated SSL Certificate Lifecycle Management
Notes: An Open-Source C++ Markdown App with Kanban Support
SuperCoder: A Terminal-Based Coding Assistant for Searching, Editing, and Debugging
Perspective: Interactive Data Visualization for the Browser and Python