Pm2: How Cluster Mode works?

Created on 19 Dec 2016  路  5Comments  路  Source: Unitech/pm2

I'd like to know more about the cluster mode solution that PM2 implements. what happens behind the curtains?

it is not explained on http://pm2.keymetrics.io/docs/usage/cluster-mode/.

can I combine it with node cluster (https://nodejs.org/api/cluster.html)?

I see it uses a custom load balancer. but how does it instantiate many instances without 'rebind the same port' problem?

All 5 comments

Our cluster mode is just a wrapper around the implementation of nodejs, we use it to abstract the cluster logic for your application. Since we just use the nodejs implementation, there isnt any custom load balancing.

just for curiosity, could you give me a high-level idea how the wrapper works? I don't like to use something that works like a 'black box' or 'magic tool', 'miraclely' solving a problem. It can help me and of course, someone else when designing systems. I'm reading the pm2 codes but it can take a while before I have a good idea of what it is going on.

I'm sorry for any inconvenience and thank you a lot.

We don't have any written explaination on how it works, so the only way for you would be to start from the entry point (pm2 start) and dive in our codebase to understand how it works, see here, here and here

thanks. it is a good start point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexpts picture alexpts  路  3Comments

phra picture phra  路  3Comments

psparago picture psparago  路  3Comments

jubairsaidi picture jubairsaidi  路  3Comments

morfies picture morfies  路  3Comments