Load Balancing Algorithms: How to Pick a Server
Load balancing algorithms are the rules a client uses to pick one server from a pool of identical backends. They're used by web proxies routing user traffic and by microservices calling each other.
Why it exists
Modern services are built for reliability and scale by running many identical, interchangeable server processes, often called backends. With hundreds or thousands of backends available, a system needs a logical way to distribute incoming work across them. Without a deliberate strategy, some servers would become overloaded while others sit idle, defeating the purpose of having a large pool.
The mental model
Think of a client as a dispatcher and the backends as a fleet of identical taxis. For every incoming ride request (a query), the dispatcher must decide which taxi to send. A naive policy is to just send the next taxi in line. A smarter policy is to send the taxi that is closest and currently has no passenger. Load balancing algorithms are these dispatching policies for network traffic.
How it works
When a client task needs something from a service, it consults a list of all available backend tasks for that service. It then runs an algorithm to select a single backend from that list and sends the query. This selection happens for each query, or for the life of a connection. The ideal goal is to spread the load perfectly evenly. In a complex system, this is a chained event: a frontend server picks an application server, which in turn acts as a client to pick a database server, with each step involving a load balancing decision.
When to use it
This is a fundamental pattern for any distributed system where multiple servers perform the same function. It's essential for stateless web applications, API gateways, microservice-to-microservice communication, and distributing reads across database replicas. If you have multiple homogeneous processes providing a service, you need a load balancing policy.
When not to use it
Load balancing is not needed for a service running on a single machine with no redundancy. It's also less applicable when backends are not interchangeable—for example, if each server is specialized for a different function. The core concept applies to pools of homogeneous, stateless servers.
One canonical example
Google's Frontend (GFE) is a reverse proxy system that handles all incoming HTTP requests. When a user's request arrives, the GFE acts as a client. It uses load balancing algorithms to select one specific backend process from the thousands running the target application. That backend processes the query. This same pattern repeats internally, as that backend might itself act as a client to call other services (like ads or authentication), using load balancing to pick backends for those services.
Interview question
Which scenario would render a load balancing algorithm ineffective or unnecessary?
- a.A web application designed with a large pool of interchangeable, stateless servers.
- b.A system where each backend server is uniquely responsible for a specific, distinct task.Correct
- c.A microservice architecture where services frequently call each other.
- d.A database cluster distributing read queries across multiple identical replicas.
Why? this is the answer
Load balancing algorithms are designed to distribute work across a pool of *identical* and *interchangeable* servers. If each server specializes in a distinct task, a client cannot randomly pick one; it must select the specific server for that task, making a general load balancing algorithm ineffective. The other options describe ideal use cases for load balancing.
Just read this? Test yourself on what you have been reading.
Read the original → sre.google
- #load balancing
- #distributed systems
- #sre
- #scalability
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles