When self-hosting n8n on a Linux KVM instance, the single most common production failure is not CPU saturation—it is V8 heap OOM kills combined with unpruned PostgreSQL execution logs under concurrent webhook bursts.
Below is the exact deterministic sizing breakdown and Queue Mode docker-compose.yml baseline we use to stop silent workflow drops.
1. Why Single-Instance n8n OOM-Kills Under Webhook Bursts
In default single-process mode (EXECUTIONS_MODE=regular), one Node.js container handles:
- The editor UI and REST API
- Cron triggers and incoming webhooks
- Heavy JSON payload transformations and LLM/HTTP polling loops
Once peak concurrency crosses ~5 simultaneous executions, Node's heap climbs rapidly:
Main Process Base : ~450 MB
Per Active Workflow : ~18 MB
Per Concurrent Burst : ~85–120 MB (large binary/JSON items)
PostgreSQL 17 Buffer : 25% of total system RAM
Linux + Docker Reserve: ~650 MB
On a 2 GB instance, a single 10-webhook burst triggers the Linux OOM killer (dmesg -T | grep -i oom) and drops in-flight executions silently.
2. Production Queue Mode Architecture (PostgreSQL 17 + Redis + Worker)
Separating the main webhook receiver from dedicated worker processes (EXECUTIONS_MODE=queue) keeps webhook ingestion responsive even during long-running API loops:
services:
postgres:
image: postgres:17-alpine
restart: unless-stopped
command:
- postgres
- -c
- shared_buffers=2048MB
- -c
- work_mem=16MB
- -c
- max_connections=120
volumes:
- pg_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
restart: unless-stopped
command: ["redis-server", "--maxmemory", "256mb", "--maxmemory-policy", "noeviction"]
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: unless-stopped
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
EXECUTIONS_DATA_PRUNE: "true"
EXECUTIONS_DATA_MAX_AGE: "168"
NODE_OPTIONS: "--max-old-space-size=2048"
n8n-worker:
image: docker.n8n.io/n8nio/n8n:latest
restart: unless-stopped
command: worker --concurrency=10
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
EXECUTIONS_MODE: queue
QUEUE_BULL_REDIS_HOST: redis
NODE_OPTIONS: "--max-old-space-size=2048"
3. Three Diagnostic Checks Before Scaling Up
Run these directly on your Linux host before resizing hardware:
# 1. Confirm whether Node or Postgres hit the kernel OOM killer
dmesg -T | grep -iE 'killed process|out of memory' | tail -n 10
# 2. Check active container memory & swap pressure
docker stats --no-stream --format 'table {{.Name}} {{.CPUPerc}} {{.MemUsage}} {{.MemPerc}}'
# 3. Verify PostgreSQL execution_entity table bloat
docker exec -i $(docker ps -qf name=postgres) psql -U n8n -c "SELECT pg_size_pretty(pg_total_relation_size('execution_entity'));"
Always provision a 4 GB swapfile with vm.swappiness=10 as a crash cushion, and keep EXECUTIONS_DATA_PRUNE=true enabled so PostgreSQL storage stays flat over months of operation.
If you want to model exact vCPU, RAM, PostgreSQL shared_buffers, and worker count for your own workflow volume before provisioning, you can run the deterministic sizing model directly here:
Top comments (0)