n8n Queue Mode
A production-ready n8n stack configured for queue mode, enabling horizontal scaling of workflow executions. PostgreSQL 16 serves as the primary data store for workflows, credentials, and execution history, while Redis acts as the message broker for distributing work across n8n worker processes. The main n8n instance handles the web editor and webhook triggers, while the worker service processes queued executions independently. This architecture is ideal for high-volume automation scenarios where a single n8n instance would bottleneck on long-running workflows. All services include health checks, resource limits, and named volumes for data durability across restarts.
Enthaltene Services
n8n
n8nio/n8n:1.73.1
Umgebungsvariablen:
n8n_worker
n8nio/n8n:1.73.1
Umgebungsvariablen:
postgres
postgres:16-alpine
Umgebungsvariablen:
redis
redis:7-alpine
Generiertes YAML
# Generated by ComposeHub (composehub.dev)
name: n8n-postgres
services:
n8n:
image: n8nio/n8n:1.73.1
restart: unless-stopped
ports:
- 5678:5678
volumes:
- n8n_data:/home/node/.n8n
environment:
N8N_HOST: ${N8N_HOST:-localhost}
N8N_PORT: "5678"
N8N_PROTOCOL: ${N8N_PROTOCOL:-http}
WEBHOOK_URL: ${WEBHOOK_URL:-http://localhost:5678/}
GENERIC_TIMEZONE: ${GENERIC_TIMEZONE:-UTC}
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_PORT: "5432"
DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n}
DB_POSTGRESDB_USER: ${POSTGRES_USER:-n8n}
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
QUEUE_BULL_REDIS_PORT: "6379"
QUEUE_HEALTH_CHECK_ACTIVE: "true"
N8N_METRICS: ${N8N_METRICS:-true}
N8N_DIAGNOSTICS_ENABLED: ${N8N_DIAGNOSTICS_ENABLED:-false}
EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-168}
networks:
- backend
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- wget --no-verbose --tries=1 --spider http://localhost:5678/healthz || exit 1
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "2.00"
memory: 1024M
reservations:
cpus: "0.50"
memory: 256M
labels:
com.composeforge.description: n8n main instance (web editor and webhook receiver)
n8n_worker:
image: n8nio/n8n:1.73.1
restart: unless-stopped
command:
- worker
volumes:
- n8n_data:/home/node/.n8n
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_PORT: "5432"
DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n}
DB_POSTGRESDB_USER: ${POSTGRES_USER:-n8n}
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
QUEUE_BULL_REDIS_PORT: "6379"
GENERIC_TIMEZONE: ${GENERIC_TIMEZONE:-UTC}
N8N_DIAGNOSTICS_ENABLED: ${N8N_DIAGNOSTICS_ENABLED:-false}
networks:
- backend
depends_on:
n8n:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- wget --no-verbose --tries=1 --spider http://localhost:5679/healthz || exit 1
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "2.00"
memory: 1024M
reservations:
cpus: "0.50"
memory: 256M
labels:
com.composeforge.description: n8n worker for queue-mode execution processing
postgres:
image: postgres:16-alpine
restart: unless-stopped
command:
- postgres
- "-c"
- shared_buffers=256MB
- "-c"
- effective_cache_size=768MB
- "-c"
- work_mem=16MB
- "-c"
- max_connections=100
- "-c"
- checkpoint_completion_target=0.9
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB:-n8n}
POSTGRES_USER: ${POSTGRES_USER:-n8n}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
networks:
- backend
healthcheck:
test:
- CMD-SHELL
- pg_isready -U ${POSTGRES_USER:-n8n} -d ${POSTGRES_DB:-n8n}
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composeforge.description: PostgreSQL 16 database for n8n workflow and execution storage
redis:
image: redis:7-alpine
restart: unless-stopped
command:
- redis-server
- "--maxmemory"
- 256mb
- "--maxmemory-policy"
- noeviction
- "--appendonly"
- yes
- "--appendfsync"
- everysec
- "--save"
- "60"
- "1000"
volumes:
- redis_data:/data
networks:
- backend
healthcheck:
test:
- CMD
- redis-cli
- ping
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: "0.50"
memory: 320M
reservations:
cpus: "0.10"
memory: 64M
labels:
com.composeforge.description: Redis message broker for n8n queue mode
networks:
backend:
driver: bridge
volumes:
n8n_data:
driver: local
postgres_data:
driver: local
redis_data:
driver: local
Kurzinfo
- Services
- 4
- Netzwerke
- 1
- Volumes
- 3
Wann verwenden
Dieses Template ist ideal für die Einrichtung einer n8n queue mode Umgebung. Alle Services sind mit Healthchecks, Ressourcenlimits und sinnvollen Standardwerten vorkonfiguriert. Passen Sie die Umgebungsvariablen an, bevor Sie in Produktion gehen.
Tipps
- Ändern Sie alle Standardpasswörter vor dem Deployment
- Überprüfen Sie die Ressourcenlimits für Ihre Hardware
- Fügen Sie einen Reverse Proxy für HTTPS in Produktion hinzu
- Konfigurieren Sie Backup-Strategien für Daten-Volumes