What Is Load Balancing and How Does It Work?

Ashish Dubey
Marketing Leader
Published:
October 31, 2026
Updated:
November 17, 2026

Load balancing refers to distributing incoming requests between multiple servers instead of directing all requests to just one of them. A special software solution that carries out such distribution is referred to as a load balancer. It sits in front of your servers, receives the requests, and redirects them.

There are two important things about it. First, no server gets overloaded with requests, and, second, in case one of the servers goes down, the load balancer identifies that and stops sending the traffic there. So your clients would not notice anything.

⚑ TL;DR
  • A load balancer spreads incoming requests across several servers so no single one is overloaded and traffic keeps flowing if one fails.
  • Layer 4 balancers route on IP and port. Layer 7 balancers read the request, such as the URL or headers, and route on that.
  • LLM traffic needs smarter balancing than round robin, because one request can take milliseconds and the next can take a minute.
What is load balancing

How does load balancing work?

  1. A request reaches the address of the load balancer.
  2. Health checks inform the balancer of which servers are online, and it skips the failed ones.
  3. The algorithm chooses a server among the healthy ones.
  4. The request is forwarded and the reply comes from the server back through the load balancer to the client.
  5. Optionally, it keeps a session on one server by means of a cookie or hashing if needed by the application.
How load balancing works

Common load balancing strategies

Load balancing strategies
AlgorithmHow it picks a serverBest for
Round robinTakes servers in turnSimilar servers and similar, short requests
Weighted round robinGives bigger servers more turnsMixed server sizes
Least connectionsPicks the server with the fewest open requestsRequests that vary in length
Least response timePicks the fastest server right nowLatency-sensitive services
IP or consistent hashMaps a client or key to the same serverSticky sessions and caches

The power of two choices is a popular technique in big systems. It selects two servers randomly and forwards the request to the less busy one. It provides almost the same effect as least connections without tracking the status of all servers.

Layer 4 vs Layer 7 load balancing

Layer 4 (transport)Layer 7 (application)
Routes onIP address and portURL path, headers, cookies, method
SpeedFaster, less inspectionSlower, more work per request
Can doForward TCP or UDP trafficTLS termination, path routing, rate limits, retries
Typical useDatabases, game servers, raw TCPWeb apps, APIs, microservices

Cloud providers offer both types, like AWS Network Load Balancer and Application Load Balancer. In Kubernetes, a Service distributes the traffic between the pods, and an Ingress or Gateway API controller takes care of Layer 7 routing. NGINX, HAProxy, Envoy and Traefik are the typical open source solutions.

Load balancing for LLM and AI workloads

Model serving violates the assumptions of round robin. One request may return in 200 milliseconds, while the next may stream for a minute, and a replica with a long queue would look the same as an idle one if you count requests per turn.

  • Balance on load, not turns. Route to the replica with the least in-flight requests or the shortest queue.
  • Respect the cache. Sending the repeated prompt prefix to the replica that already has it would save some GPU processing. Some inference routers do that.
  • Scale with demand. Combine the balancer with autoscaling so that new replicas would join the pool on load increase.
  • Balance across providers as well. A gateway may distribute traffic among the model providers and switch off one provider when it becomes slow or rate-limited.

Balance LLM traffic across models and providers

TrueFoundry's AI Gateway routes requests across models and providers with weights, latency-based routing and fallbacks, so one slow or failing endpoint does not take your app down.

Book a demo β†’

The TrueFoundry AI Gateway does this at the model layer. You define the models behind one endpoint, then configure weights, latency-based routing and fallbacks. Also see what is an AI gateway.

Challenges and best practices

  • Avoid the single point of failure. Deploy the load balancer itself in pairs or use the managed one.
  • Tune the health checks. Be careful about the check interval. If it is too long, the users would reach the failed servers. But if it is too aggressive, the healthy servers would be pulled down on a spike.
  • Prefer stateless services. If every server can process any request, sticky sessions would seldom be required.
  • Drain before deploying. Wait until the in-flight requests complete before decommissioning the server.
  • Track the metrics. Monitor the server latency, error rate and connection counts, and review the stats after every scaling event.
AI Gateway

One endpoint, many models, no single point of failure

See how teams route, fail over and cap spend across LLM providers from one gateway.

Related: autoscaling, service mesh and scale to zero.

1. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,Β 
2. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,Β 
3. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,Β 
Table of Contents

Govern, Deploy and Trace AI in Your Own Infrastructure

Book a 30-min with our AI expert

Book a Demo

Frequently Asked Questions

What is load balancing in simple terms?

It is distributing incoming requests among a number of servers to prevent any one of them from being overwhelmed. A load balancer sits at the front, selects a healthy backend for every request, and keeps the application fast and available.

What are the main load balancing strategies?

Round-robin distributes requests equally among all backends, least-connections directs traffic to the least busy backend, and latency-based routing chooses the quickest-responding one. Load-aware strategies are best for variable workloads like LLM requests.

How does load balancing improve availability?

By running health checks and passing requests only to backends that are up and responsive. If one fails, the balancer sends traffic to the others, so the application keeps working instead of going down with a single server.

Why does load balancing matter for LLMs?

Because LLM replicas are expensive and scarce, and requests vary in cost. Balancing keeps replicas evenly and fully used, avoids overloading any one, and can route across models and providers to balance speed, cost, and reliability.

How is load balancing related to autoscaling?

Load balancing distributes traffic among the backends you have; autoscaling changes how many backends there are. In combination they let an application both use its current capacity well and add or remove capacity as demand changes.

Grey wavy lines on white background, abstract wave pattern with multiple curved lines intersecting smoothly.

GenAI infra- simple, faster, cheaper

Trusted by Top Teams to Scale GenAI