DEV Community

QuickStack Media
QuickStack Media

Posted on Edited on

Self-Hosting n8n on a VPS vs Cloud: 2026 Docker Queue-Mode Cost & Scaling Guide

Architecting a modern workflow automation pipeline requires balancing sub-second execution latency against predictable resource consumption under high concurrent load. Choosing between a managed cloud tier and a self-hosted Docker architecture dictates how your infrastructure handles backpressure, memory leaks, and horizontal worker scaling.

Architectural Paradigms: Standalone vs. Queue-Mode

Running n8n on a single VPS using standard single-process execution works well for low-volume orchestration, but it introduces critical bottlenecks once concurrency spikes. The process memory bounds your throughput, meaning a single memory-intensive JavaScript code node can crash the entire instance and drop active webhooks.

For high-throughput environments processing tens of thousands of webhooks, self-hosting requires transitioning to an n8n Queue Mode deployment. This architecture decouples the main API handling process from the actual execution engine by introducing a Redis message broker.

  • API / Webhook Node: Accepts incoming HTTP requests, validates payloads, and immediately pushes execution jobs to Redis, returning a 200 OK to the webhook sender without waiting for downstream processing.
  • Redis Broker: Acts as an in-memory queue management layer, safely holding payloads and maintaining execution state across worker nodes.
  • Worker Nodes: Stateless Docker containers that pull jobs from the Redis queue, execute workflows, and write logs back to the persistent database.
  • Database (PostgreSQL): Stores workflow definitions, credentials, and historical execution logs, requiring connection pooling (via PgBouncer) under high worker concurrency.

While platforms like Make abstract infrastructure management completely through metered operational pricing, a self-hosted queue setup hands over total control of data locality, payload sizes, and runtime limits to your engineering team.

Resource Profiling and Sizing the VPS

To accurately benchmark self-hosted infrastructure, we must profile the memory and CPU footprints of individual n8n components. A standard worker container running Node.js requires a baseline of 512MB RAM, scaling up to 2GB RAM under heavy payload transformation (e.g., parsing multi-megabyte JSON payloads or handling binary file attachments).

Production Infrastructure Requirements

  • Load Balancer / Reverse Proxy: Nginx or Caddy handling SSL termination and rate limiting.
  • Main n8n Instance: 1 vCPU, 2GB RAM for webhook ingestion, UI access, and queue dispatching.
  • Redis Instance: 1 vCPU, 1GB RAM (configured with maxmemory-policy volatile-lru).
  • Worker Pods (x2 min): 2 vCPUs, 4GB RAM per worker container to prevent V8 heap out-of-memory errors.
  • Database: Managed PostgreSQL (or a dedicated VPS instance) with provisioned IOPS.

When comparing alternatives, teams often weigh self-hosted complexity against SaaS platforms like Make, where scaling compute limits is handled upstream by the provider rather than your DevOps rotation.

Total Cost of Ownership (TCO) & Line-by-Line Math

Evaluating TCO requires looking past the base VPS pricing to include database backups, Redis memory overhead, outbound bandwidth, and engineering maintenance hours. Below is the deterministic cost breakdown across three scaling tiers assuming an average workflow complexity of 5 steps per run.

At 10,000 Monthly Runs

  • Infrastructure: 1x 4 vCPU / 8GB RAM VPS (DigitalOcean/Hetzner) at $24/month.
  • Managed Add-ons: Basic managed PostgreSQL instance at $15/month.
  • Bandwidth & Storage: Negligible egress and 50GB block storage at $5/month.
  • Engineering Overhead: Estimated 1 hour/month maintenance at $75/hour.
  • Total Monthly Cost: $119.00 (Effective cost per 1k runs: $11.90).

At 50,000 Monthly Runs

  • Infrastructure: Scaled cluster with 1x API node ($24) and 2x Worker nodes ($48 total).
  • Managed Add-ons: Production-tier PostgreSQL with automated backups at $30/month.
  • Bandwidth & Storage: Increased log retention and payload processing at $15/month.
  • Engineering Overhead: Estimated 3 hours/month for updates and queue tuning at $225/hour.
  • Total Monthly Cost: $342.00 (Effective cost per 1k runs: $6.84).

At 100,000 Monthly Runs

  • Infrastructure: High-availability cluster with load balancer, Redis cluster, and 4x Worker nodes ($140 total).
  • Managed Add-ons: High-availability managed PostgreSQL with connection pooling at $75/month.
  • Bandwidth & Storage: Heavy data egress and 200GB fast NVMe storage at $40/month.
  • Engineering Overhead: Estimated 5 hours/month for security patching and scaling at $375/hour.
  • Total Monthly Cost: $630.00 (Effective cost per 1k runs: $6.30).

Docker Compose Production Blueprint

To deploy a resilient queue-mode environment, your docker-compose.yml must isolate the webhook handler from worker execution threads while ensuring proper health checks and restart policies.

version: '3.8'

volumes:
  db_storage:
  redis_storage:

networks:
  n8n-internal:
    driver: bridge

services:
  postgres:
    image: postgres:15-alpine
    restart: always
    environment:
      POSTGRES_DB: n8n
      POSTGRES_USER: n8n_user
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - db_storage:/var/lib/postgresql/data
    networks:
      - n8n-internal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U n8n_user -d n8n"]
      interval: 5s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    restart: always
    volumes:
      - redis_storage:/data
    networks:
      - n8n-internal
    command: redis-server --requirepass ${REDIS_PASSWORD}
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5

  n8n-import:
    image: n8nio/n8n:latest
    networks:
      - n8n-internal
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n_user
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
    entrypoint: /bin/sh
    command: "-c \"n8n import:community --all || true\""
    depends_on:
      postgres:
        condition: service_healthy

  n8n-api:
    image: n8nio/n8n:latest
    restart: always
    networks:
      - n8n-internal
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n_user
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_PASSWORD=${REDIS_PASSWORD}
      - WEBHOOK_URL=https://n8n.yourdomain.com/
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy

  n8n-worker:
    image: n8nio/n8n:latest
    restart: always
    networks:
      - n8n-internal
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n_user
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_PASSWORD=${REDIS_PASSWORD}
    command: worker
    deploy:
      replicas: 2
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy
Enter fullscreen mode Exit fullscreen mode

Selection Matrix

Evaluation Criteria Self-Hosted VPS (Queue Mode) Cloud SaaS / Managed Tier
Data Sovereignty 100% on-premise or private cloud; ideal for HIPAA/GDPR strict compliance. Handled via third-party cloud infrastructure and sub-processors.
Scaling Dynamics Manual or scripted Docker replica adjustments; requires proactive capacity planning. Elastic auto-scaling managed natively by the platform provider.
Maintenance Burden High (OS patching, Redis tuning, DB backups, container orchestration). Zero infrastructure management; updates are automatically applied.
Cost Predictability Fixed monthly infrastructure costs regardless of execution payload sizes. Variable operational pricing tied directly to task or execution volume.
Execution Limits Bound only by VPS CPU/RAM specs and storage limits. Subject to strict timeouts, payload size caps, and concurrency throttling.

Disclosure: QuickStack Media may earn an affiliate commission when you sign up through links in our benchmarks at no extra cost to you.

Top comments (0)