I'm building an stateless Web application using Node.js, Express and pm2 for process management. In production environments, I run one instance of the application for each core of the server CPU (thanks to pm2 cluster mode).
Recently I started to read about Greenlock-Express (for obtaining certificates automatically) and it also has a "cluster" property, which if I understand correctly it basically does the same thing as pm2 cluster mode.
Will there be any collisions or possible issues if I run both Greenlock-Express and pm2 in cluster mode? If they do, what's the best alternative to obtain automatically SSL certificates with Node.js in a Windows enviroment? And if they do not, is it optimal to use both of them in cluster mode?
PM2 only implements partial cluster support.
See https://git.rootprojects.org/root/greenlock-express.js/issues/26
I'd recommend just using
serviceman(cross-platform) or rawsystemd(linux) orDocker(cloud deploys).If you are going to use PM2, you use Greenlock Express with it the same way that you would use it with Ruby, Python, etc - as a separate executable, not as a "built-in" app.
PM2s default optimizations for node apps are already implemented in Greenlock Express, and since PM2 only has partial cluster support, there's not a way to tell PM2 to pass control to Greenlock Express, nor to have PM2 accept control from Greenlock Express.
Also: Only use
clustermode if you actually have multiple CPU cores otherwise you'll cause thread thrashing and slow down your process.