Bare-Metal & VPS Production Hosting: Scaling Node.js & FastAPI with PM2, Systemd, and Nginx
A field guide to hardening Linux VPS environments, configuring PM2 clustering across CPU cores, managing FastAPI background daemons with Systemd units, and setting up an optimized Nginx reverse proxy with HTTP/2 and Brotli compression.

Production VPS Architecture without PaaS Overheads
When maximizing raw hardware performance per dollar, running services directly on Ubuntu Linux with PM2 process manager and Systemd service supervision offers unrivaled low-latency execution and direct kernel I/O throughput.
1. Node.js Cluster Mode with PM2
Using ecosystem.config.cjs with instances: "max" and exec_mode: "cluster" spreads incoming Node.js requests across all available CPU cores. Automatic memory ceiling restarts (max_memory_restart: "500M") and zero-downtime reloads (pm2 reload all) keep services resilient.
2. FastAPI Systemd Service Units & Nginx Reverse Proxy
FastAPI applications are supervised using Systemd service units configured with Uvicorn worker pools, automated restarts on failure, and environment file loading. Nginx terminates TLS 1.3, handles Brotli compression, and proxies upstream traffic via Unix domain sockets.

Jaykumar Kanjia
Sr. Software Engineer specializing in scalable backend architectures, high-performance Redis caching, and autonomous AI agent workflows.
