PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
Starting an application in production mode is as easy as:
When an application is started with the -i option, the Cluster Mode is enabled.
The Cluster Mode start and automatically load balance HTTP/TCP/UDP between each instance. This allows to increase overall performance depending to the number of CPUs availabe.
Seamlessly supported by all major Node.js frameworks and any Node.js applications without any code change:
$ pm2 start app.js -i max # Enable load-balancer and start 'max' instances (cpu nb)
$ pm2 reload all # Zero second dowtime reload
$ pm2 scale <app_name> <instance_number> # Increase / Decrease process number
# Auto detect init system + generate and setup PM2 boot at server startup$ pm2 startup
# Manually specify the startup system# Can be: systemd, upstart, launchd, rcd$ pm2 startup [platform]
# Disable and remove PM2 boot at server startup$ pm2 unstartup