Is it better to run N docker containers or pm2 with N instances? What approach is more efficient from resources utilization (cpu/memory) point of view?
Update: I don't ask how to run node.js app using pm2 in a docker container. I want to understand what is a better setup if we talk about single instance server, run app in a multiple docker containers or in multiple threads using pm2.
There are different approaches to accomplish this, I would use a load balancer like Nginx and whatever you decide Docker containers running locally or system services, take a look at these articles:
Nginx + Docker: https://auth0.com/blog/load-balancing-nodejs-applications-with-nginx-and-docker/
Nginx + systemd: https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/ https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-2/
first part explains how to configure your app as a systemd service and the second how to launch multiple processes
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.