简体   繁体   中英

Does nodejs Master process utilize all the cpu memory?

Trying to understand how nodejs works in terms of cpu memory usage we have 4 instances in prod that are slowing down because of heavy lifting and we have load balancer in place. would it make sense to add node-cluster at instance/app level so we can use all the hardware capabilities using cluster.fork so all the child processes can also listen to the port directly. what would be better approach add more instances to load balancer or add node-cluster or third party PM2 etc for handling heavy load ?

The ways of scaling out your node app -- cluster.fork or loadbalancing multiple instances -- will work.

If you have loadbalancing working without pm2 it might not make sense to add it to the mix at this point, because complexity.

One other thing to consider: if your nodejs instances are running https servers, not http servers, you may want to use nginx as a reverse proxy, and have it handle the https crypto work. You can have nginx forward requests to your node instance at http://localhost:3000 . https -handling is compute intensive, and nginx does it more efficiently than nodejs does.

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