简体   繁体   中英

Should I use Node.js Greenlock-Express with cluster mode at the same time I'm using pm2 cluster mode?

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 raw systemd (linux) or Docker (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 cluster mode if you actually have multiple CPU cores otherwise you'll cause thread thrashing and slow down your process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM