WorkflowTCO
Infrastructure Reference Manual

Production Self-Hosted n8n Queue Mode Architecture (Redis, Postgres & Backups)

Architect crash-proof self-hosted n8n clusters splitting main UI, stateless webhook ingress, Redis BullMQ brokers, and horizontal worker containers—paired with PostgreSQL execution pruning, secret rotation, and hidden-origin Cloudflare Tunnel ingress.

Audited Segment Vendor Scorecard — Production Self-Hosted n8n Container & VPS Cloud Shortlist

PlatformEntry Cloud FloorQueue-Ready TierOps Setup ScoreIdeal Hosting ProfileLive Rates
Railway
Managed Container PaaS for Self-Hosted n8n
$5/monthPro Queue-Mode Cluster ($20/mo)4/10 frictionFastest self-hosted n8n queue-mode cloud deploymentPricing →
DigitalOcean
Flat-Rate Cloud Droplets & Managed Postgres
$12/monthGeneral 4vCPU / 8GB Queue Node ($48/mo)5/10 frictionHigh-bandwidth self-hosted automation with predictable VPS capsPricing →
Hostinger VPS
Entry KVM VPS & Prebuilt n8n Templates
$6.99/monthKVM 4 (4 vCPU / 16 GB RAM) ($10.99/mo)4/10 frictionSolo builders & agencies running cost-capped n8n nodesPricing →
Cloudways
Managed Multi-Cloud Server Orchestrator
$14/monthDO8GB Managed Agency Cluster ($99/mo)3/10 frictionAgencies wanting self-hosted economics without raw Linux opsPricing →

Runway weight equation: cluster_reliability = (0.35 * redis_aof_durability) + (0.30 * webhook_worker_isolation) + (0.20 * automated_pg_backup) + (0.15 * memory_headroom) · Audited 2026-11-22 · Sources archived in /llms-full.txt.

Procurement Verification Checklist

  1. Set EXECUTIONS_MODE=queue, QUEUE_BULL_REDIS_HOST, and OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=true so neither UI edits nor incoming webhooks ever compete with CPU-heavy AI/PDF worker containers.
  2. Deploy four distinct services: n8n-main (editor UI + scheduler, 1.5 GB RAM), n8n-webhook (stateless HTTP ingress returning 200 OK in <70ms), n8n-worker (2-4 replicas at 1.25 GB RAM each), plus Redis 7 (appendonly yes) and PostgreSQL 16.
  3. Generate a cryptographically random 32-byte N8N_ENCRYPTION_KEY stored in your external secrets manager before creating your very first credential—identical across main, webhook, and all worker containers.
  4. Enforce aggressive database hygiene via EXECUTIONS_DATA_PRUNE=true, EXECUTIONS_DATA_MAX_AGE=168 (7 days), and EXECUTIONS_DATA_SAVE_ON_SUCCESS=none for high-volume non-financial webhooks so PostgreSQL disks never hit 100%.
  5. Schedule automated nightly encrypted pg_dump snapshots streaming straight to Cloudflare R2 or S3, and perform a quarterly cold-restore drill onto a staging node verifying workflow + credential decryption.
  6. Bind all container ports strictly to 127.0.0.1 and expose webhook/UI routes exclusively behind Cloudflare Tunnel (cloudflared) or private VPC load balancers so origin server IPv4 addresses never appear in public DNS.
PlatformEntry Tier CapOverage Unit12m Baseline
Default SQLite Single Node>20 RPS webhook burstSQLITE_BUSY 502 failures19.6% lost events
Unpruned Postgres Execution Logs200k runs w/ binary JSON100% NVMe disk lockup in 45dTotal cluster outage
Lost N8N_ENCRYPTION_KEYContainer rebuild w/o vaultAll OAuth credentials unreadable16-30 hrs re-auth
Exposed Origin IPv4 + Port 5678Public DNS A record leakDirect DDoS & bot scansZero via CF Tunnel

Deep-Dive Calculators & Matchups

Preventing Binary Data OOM Crashes & Silent PostgreSQL Disk Exhaustion

Two operational pitfalls account for almost every self-hosted n8n emergency page. First, default in-memory binary handling (N8N_DEFAULT_BINARY_DATA_MODE=default) buffers PDFs, audio recordings, and images straight inside V8 RAM; ten concurrent 40 MB webhook files immediately trigger Linux OOM-killer crashes. Switching to N8N_DEFAULT_BINARY_DATA_MODE=filesystem backed by a shared volume or S3 external storage flattens worker memory draw dramatically.

Second, storing full JSON execution inputs and outputs for 500,000 monthly webhooks bloats PostgreSQL tables past 60 GB within weeks. Pruning successful low-risk runs after 7 days while archiving critical Stripe/ERP audit hashes in a lean custom SQL table keeps database size below 4 GB indefinitely.

  • Pin exact Docker image tags (e.g., n8nio/n8n:1.x.y) rather than :latest so automated container restarts never apply breaking schema migrations unannounced.
  • Expose n8n’s /metrics Prometheus endpoint on internal loopback to alert Slack whenever BullMQ waiting job depth stays above 250 for more than 3 minutes.
  • Set DB_POSTGRESDB_POOL_SIZE appropriately across worker replicas (e.g., 10 per worker x 4 workers = 40 connections) well beneath Postgres max_connections=100.

Category Buyer Questions

Can Redis queue mode run on a single $10.99/mo Hostinger KVM4 or $48/mo DigitalOcean droplet?

Yes. Running Docker Compose with n8n-main, n8n-webhook, 2-4 n8n-workers, Redis, and PostgreSQL inside a single 8 GB to 16 GB host unlocks full event-loop isolation and ~960-1,120 runs/min without multi-node Kubernetes complexity.

What happens to in-flight jobs if an n8n worker container restarts during a Railway deployment?

BullMQ tracks active job locks in Redis; stalled jobs whose worker fails to renew its heartbeat automatically re-enter the queue after QUEUE_WORKER_LOCK_DURATION expires and are picked up by healthy workers.

Why must n8n-main, n8n-webhook, and n8n-worker all share the exact same N8N_ENCRYPTION_KEY?

Credentials stored in PostgreSQL are encrypted symmetrically using N8N_ENCRYPTION_KEY; if a worker boots with a mismatched or missing key, every authenticated API node fails immediately with decryption errors.