How to handle a lot of load with node.js server?

My node.js server will handle 50k concurrent clients. The only node.js server is not capable of handling this amount of load. I suppose to set up 5 or 10 node.js servers running on different ports. And, have a load balancer, for example. Nginx listening on each node.js. server When one server reaches 10k clients, redirect redundant incoming connections to other node.js servers. Is this the right way to handle such a load with node.js? If not, what is the best practice?

+4
source share
1 answer

The easiest way to handle the load is to really use a load balancer to forward requests to another server on the same computer or on remote machines.

If you want to configure the servers on only one computer, use pm2 , it will take care of load balancing and maintaining your servers.

Remember that working on one computer does not give you high availability, and in the event of an accidental shutdown, your service will be unavailable.

I would advise starting the server on several single-core machines than on a single multi-core machine. To do this, configure pm2 / forever on each machine and another machine to run nginx to balance the load.

This article should start with nginx.

+2
source

Source: https://habr.com/ru/post/1611268/


All Articles