Help to deal with the clustering of pm2 and built into node js. Below is the code of the app.js file, which will be launched by the pm2 manager.

enter image description here

I am using inline node clustering. After starting, I see the command pm2 monit:

enter image description here

4 workers, memory 37 MB.

Now we get rid of clustering the node by running the worker directly.

enter image description here

And tell pm2 to use clustering.

enter image description here

We get 4 workers, each with 44 MB of memory.

I want to understand why it is better to use? Why 4 clusters of nodes eat less mem than a single pm2 cluster? Maybe I did not understand something?

    1 answer 1

    He asked, he answered. pm2 just starts several identical processes, and acts as a balancer. Also, pm2 provides a convenient api for working with its "clusters".