97 The main difference between fork_mode and cluster_mode is that it orders pm2 to use either the child_process.fork api or the cluster api.
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. By default, pm2 will use
node so that
pm2 start server.js will do something like:
This mode is very useful because it enables a lot of possibilities. For example, you could launch multiple servers on pre-established ports which will then be load-balanced by HAProxy or Nginx.
cluster will only work with
node as it's
exec_interpreter because it will access to the nodejs cluster module (eg:
fork methods etc.). This is great for zero-configuration process management because the process will automatically be forked in multiple instances.
pm2 start -i 4 server.js will launch 4 instances of
server.js and let the cluster module handle load balancing.
A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.
We are providing robust Node.JS Development Services with expert Node.js Developers. Get affordable Node.JS Web Development services from Skenix Infotech.
A thoroughly researched list of top NodeJS development companies with ratings & reviews to help hire the best Node.JS developers who provide development services and solutions across the world. List of Leading Node.js development Service Providers...
The practical implications of having Streams in Node.js are vast. Nodejs Streams are a great way to handle data chunks and uncomplicate development.
🔥 Node.js Certification Training: https://www.edureka.co/nodejs-certification-training This Edureka video on 'Node.js Docker Tutorial' will help you in learn...