PM2 Zero‑Instance Scaling: Auto‑Stop Timeout Configuration
0 reputation · 09 May 2024, 15:00 UTC
Goal
Reduce hosting costs by allowing a Node.js application managed by PM2 to automatically stop all instances when traffic drops to zero.
Current Constraint
PM2 lacks a built‑in mechanism to trigger a stop after a configurable period of inactivity. Users must rely on external scripts that monitor request rates and invoke pm2 stop or pm2 delete.
Uncertainty
It is unclear whether a future PM2 version will expose a native auto‑stop option, and how permission boundaries affect the ability of monitoring scripts to control PM2 processes on shared hosting environments.
Questions
- Can PM2 be configured to automatically stop all instances after a defined idle timeout without external tooling?
- What permission model is required for a monitoring daemon to safely invoke pm2 stop/start commands on behalf of the application?
- How do the behaviors of
pm2 stopversuspm2 deleteimpact restart latency and environment variable re‑initialization when scaling to zero?