Node.js › Clustering & Worker Threads

How does PM2's cluster mode compare to manually using Node's built-in cluster module directly in application code?

Intermediate

Answer

PM2's cluster mode achieves the same goal at the process-manager level, without needing cluster-aware application code, and additionally provides zero-downtime reloads, automatic restarts, and log aggregation that would need to be built manually with the raw cluster module.
pm2 start server.js -i max --name my-app

// server.js needs zero cluster-specific code
const app = express();
app.listen(3000);
Real-world example A team migrates from a hand-rolled cluster.js entry point to 'pm2 start server.js -i max', immediately gaining zero-downtime reloads without maintaining that logic themselves.

Common follow-ups: What does 'zero-downtime reload' mean operationally, and how does PM2 achieve it?;When would you still want the raw cluster module instead of PM2?