Node.js › Cloud & DevOps
What is a load balancer, and how does it distribute traffic across multiple Node.js application instances?
IntermediateAnswer
A load balancer sits in front of multiple instances, distributing requests according to an algorithm (round-robin, least-connections, IP-hash), improving availability (traffic routes only to healthy instances) and throughput, commonly implemented via a managed cloud load balancer or software like Nginx or HAProxy.
upstream node_app {
server 10.0.0.1:3000;
server 10.0.0.2:3000;
}
server {
listen 80;
location / { proxy_pass http://node_app; }
}Real-world example A production API runs three instances behind an AWS ALB configured with health checks, so a crashed instance is automatically removed from rotation until it recovers.