Load balancing algorithms beyond the basics
Round robin and least connections are the two most common starting points, but production systems often use refinements on top of them: weighted round robin, giving more powerful servers a larger share of requests, least response time, factoring in how quickly a server has been answering recently, and consistent hashing, used heavily in caching layers so the same key almost always maps to the same server even as servers are added or removed.
Load balancing in modern, cloud-native infrastructure
Beyond a single dedicated appliance, load balancing today often happens at several layers at once: a cloud provider's managed load balancer in front of the whole application, an ingress controller distributing traffic inside a Kubernetes cluster, and a service mesh handling load balancing between individual internal services. Each layer solves the same basic problem, not overloading any one instance, at a different scope.
What a load balancer cannot fix
A balancer spreads work, but it does not make a slow application fast. If every server shares one overloaded database, adding more web servers behind a balancer moves the bottleneck rather than removing it. Likewise, a balancer in front of servers that keep state locally can break logins or shopping carts. Before adding servers, find the real bottleneck with monitoring, and make the application stateless where possible.
A simple request walk-through
A visitor opens the site and their browser resolves the domain name to the balancer's address. The balancer accepts the connection, picks a healthy server using its algorithm, and forwards the request. The server builds the response, which returns through the balancer to the visitor. If that server had failed its last few health checks, the balancer would have skipped it, and the visitor would never know. Metrics such as requests per second per server, error rate, and response time are what operators watch to confirm the distribution is healthy.
Frequently Asked Questions
What happens if the load balancer itself fails?
To avoid the load balancer becoming a single point of failure, real-world deployments usually run at least two load balancers in an active-standby or active-active setup, so if one goes down the other keeps handling traffic without interruption.
Does a small website need load balancing?
Not if a single server comfortably handles its traffic. Once traffic grows enough to require multiple servers, though, a load balancer becomes essential, since there is no other way to split incoming requests across them.
Is a load balancer the same as a reverse proxy?
They overlap. A reverse proxy sits in front of servers and forwards client requests to them, and many reverse proxies can also balance load. A Layer 7 load balancer is essentially a reverse proxy with distribution and health-check features, while a Layer 4 balancer works at a lower level without reading the request.
Which algorithm should I choose?
Round robin is a sensible default for similar servers and short requests. Choose least connections when request durations vary widely, weighted variants when servers differ in size, and hashing or cookies only when you must keep users on the same server.
Can a load balancer protect against attacks?
It can absorb some traffic and hide back-end addresses, and many managed balancers add rate limiting or a web application firewall, but a balancer alone is not a complete defense against large denial-of-service attacks.