On the Difference between fork Startup Mode and cluster Mode of pm2
Does fork start only one process?
Cluster starts multiple processes
I don’t know if it is right, who can help me to answer it
Fork mode, single instance and multi-process, is commonly used in multi-language mixed editing, such as php, python, etc. It does not support port reuse and needs to do its own application’s port allocation and load balancing sub-process business code.
The disadvantage is that a single server instance is easy to crash due to exceptions.
Cluster mode, multiple instances and multiple processes, but only node is supported, ports can be reused, no additional port configuration is required, and 0 code realizes load balancing.
The advantage is that due to the multi-instance mechanism, the fault tolerance of the server can be guaranteed, and even if an exception occurs, multiple server instances will not crash at the same time.
In common, because they are all multi-processes, they all need message mechanism or data persistence to realize data sharing. If there is anything wrong, please correct me.