performance – How to optimize multiple Node.js apps on Windows Server with PM2, Nginx, and safe restarts?

I have a Windows Server running 5 Node.js apps (Next.js and Express). I’m using PM2 to manage the apps and Nginx as a reverse proxy.

My goals:

  • Reduce CPU cores and RAM usage per app.
  • Reduce project size (especially .node_modules).
  • Have a simple way to monitor apps and automatically restart them if they stop.
  • Eventually set up a deployment pipeline (CI/CD) to automate updates.

Questions / What I’m looking for:

  • Best practices for managing multiple Node.js apps on Windows with PM2 + Nginx.
  • How to safely restart apps without affecting production.
  • Better ways to monitor apps locally and handle automatic restarts.
  • How to reduce dependency conflicts when using pnpm or other package managers.
  • Suggestions, examples, or references for optimizing Node.js apps and preparing for automated deployments.

What I’ve tried and what happened:

  • I’ve tried pnpm to reduce disk usage and dependency conflicts, but some apps still fail due to dependency clashes (e.g., Ant Design + Day.js causing dropdown date errors). Occasionally, some apps fail to start.
  • For monitoring, I experimented with Grafana, pm2-metrics, and Prometheus, but none can safely restart apps automatically without external intervention.
  • I don’t want to use the PM2 web dashboard, because it’s a separate web app and I don’t want to expose internal metrics externally.

Read more here: Source link