Load Balancing in Nodejs

ぐ巨炮叔叔 提交于 2019-12-05 16:58:42

One other option you can use to cluster NodeJs applications is to deploy the app using PM2.

Clustering is just easy as this, You don't need to implement clustering by hand

pm2 start app.js -i max

PM2 is an expert to auto detect the number of available CPUs and run as many processes as possible

Read about PM2 cluster mode here http://pm2.keymetrics.io/docs/usage/cluster-mode/

For controlling the load of IO operations, I wrote a library called QueueP using the memoization concept. You can even customize the memoization logic and gain speedup values of more than 10, sometimes

https://www.npmjs.com/package/queuep

As far as I know, the built in node cluster is not a good solution yet (load is not evenly distributed across cores). Until v0.12: http://strongloop.com/strongblog/whats-new-in-node-js-v0-12-cluster-round-robin-load-balancing/

So you should use nginx until then. After that we will see some benchmarks comparing both options and see if the built in cluster module is a good choice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!