Can we use both NGINX and PM2 for node.js production deployment? Can we use both NGINX and PM2 for node.js production deployment? express express

Can we use both NGINX and PM2 for node.js production deployment?


This is a huge topic but let me help and give you some pointers.

Nginx is much more than just a reverse proxy. It can serve static content, can compress the response content, can run multiple apps on different port on the same VM and much more.

PM2 essentially helps you to scale throughput of your service by running it in cluster mode and utilizing all the cores of the box. Read this stackoverflow answer to understand more on this.

Now to answer your question

Can we use both for production?

Yes and you should. Nginx can run on port 80. PM2 can run on port 3000 (or whatever port) which can then manage traffic within the instances of the app.

gzip alone will make a huge difference in the app end user performance.

Here is a good article in case you need code help on how to set it up