Interview frequency: …
Short answer
PM2 manages the application in Cluster mode, restarts it after a crash, and enables updates without interruption by restarting processes one at a time.
Explanation
PM2 provides a complete process manager for Node.js on traditional and virtual servers. When you run pm2 reload, it signals the first process to shut down gracefully, waits for the replacement process to start and listen on the port, then moves to the next one. This keeps requests flowing without dropping connections.
Code example
// ecosystem.config.js
module.exports = {
apps: [{
name: "api",
script: "./dist/index.js",
instances: "max",
exec_mode: "cluster"
}]
};Common mistakes
- Using pm2 restart instead of pm2 reload during updates, temporarily interrupting service for all users.