Load balancing with Node v0.12.2 - cluster, pm2 or nginx

With Node v0.12.2, the cluster module supports Round-Robin (RR) load balancing , which provides more even distributed load than previous load balancing at the OS level.

So now we are spoiled for choice:

I know this excellent post , as well as others responding here , but no one turned to the new cluster module with RR mode. Therefore, the question boils down to the following:

Judging only by their load balancing capabilities, should pm2 or nginx be used?

+7
nginx load-balancing haproxy pm2
source share
1 answer

TL; DR

If it's just pm2 vs. nginx for nginx. Better : both. Best : Even broader customization.

If you want the most mature load balancing features to use HAProxy . It does one thing better . You will get an SSL termination, ACL, and it will be very easy. I can't prove it with numbers, but I feel that it has the smallest hit on HTTP requests. Good reading of this .

If you also need to serve (at least some) static content, your goto nginx option for its excellent features in this field. Also from your list, this is the only one who will provide such an opportunity. Except for node itself, but doing it is very bad.

pm2 feels very heavy IMO and tends to break more often. The process load balancing capabilities are very good and keep your node process running smoothly. It abstracts cluster .

cluster feels "fixed" to a minimum. In the past, and possibly os-level support has led to different behaviors on different platforms. For example, bias to individual processes.

My current setup:

  • HAProxy for cluster load balancing, including balancing multiple process instances per machine.
  • CDN for static content (e.g. Cloudinary )
  • pm2 for process load balancing
+4
source share

All Articles