Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 change cluster processes size at runtime

does anyone know if it is possible to change in NodeJS PM2 the number of cluster processes for an application at runtime?

regards Philipp

like image 879
Philipp Avatar asked Mar 28 '15 16:03

Philipp


People also ask

Does PM2 do load balancing?

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.

What is PM2 runtime?

PM2 Runtime 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 facilitate common Devops tasks. Starting an application in production mode is as easy as: $ pm2 start app.js.

What is fork mode in PM2?

Take the fork mode as a basic process spawning. This allows to change the exec_interpreter , so that you can run a php or a python server with pm2. Yes, the exec_interpreter is the "command" used to start the child process.

Which is better forever or PM2?

According to the StackShare community, PM2 has a broader approval, being mentioned in 74 company stacks & 107 developers stacks; compared to forever, which is listed in 3 company stacks and 3 developer stacks.


1 Answers

You can use pm2 scale to scale vertically the number of process at runtime, note that it only work with cluster mode. Example :

  • pm2 scale APPNAME 2 will scale the process to exactly 2 instances.
  • pm2 scale APPNAME +2 will add two process.
  • pm2 scale APPNAME -1 will remove one process.

source link

like image 128
vmarchaud Avatar answered Oct 02 '22 01:10

vmarchaud