What is the difference between clusters nodejs + domains and PM2?
NodeJS has its own modules for managing clustering and process restart:
-
a clustering module that allows node to run multiple processes based # on the kernel in the machine. It will also spawn new processes while shutting down old ones.
-
allows node to stop accepting requests and shutdown processes after an error occurs.
Then PM2 is in there , and I've seen guides like this one saying PM2 allows logging, some statistics monitoring, process restart and clustering for nodejs.
Besides monitoring statistics and logging, can anyone explain what is the difference between the two? Are they supposed to be used together or am I choosing one or the other?
In production, like each tariff on shutdown + restart on load for a nodejs app:
-
The system needs to be rebooted (using system patches, etc.)
-
Restarting all nodejs processes to apply new code changes to the server.
source to share