What is a load balancer?

DEFINITION

A load balancer distributes incoming traffic across multiple servers so no single server is overwhelmed, improving speed, reliability and uptime.

A load balancer sits in front of a group of servers and decides which one should handle each incoming request. Visitors connect to a single address, and the load balancer forwards their traffic to a healthy server behind it, using a method such as round robin, least connections or a hash of the visitor's address.

Layer 4 load balancers route traffic based on network information like IP addresses and ports, while Layer 7 load balancers understand HTTP, so they can route by URL path or hostname, terminate TLS, and add headers. Cloud providers offer managed load balancers, and software options exist for self-hosted setups.

Why load balancers matter

With one server, any crash, update or traffic spike can take your whole site down. A load balancer runs regular health checks and stops sending traffic to servers that fail them, so users are routed around problems automatically. It also makes scaling simple: add more servers behind it during busy periods and remove them later. Updates can be rolled out one server at a time without downtime.

Example setup

An e-commerce site expecting heavy traffic during a seasonal sale might run three application servers across two availability zones behind a managed load balancer. The load balancer handles HTTPS certificates, checks a health endpoint on each server every few seconds, and works with autoscaling to add servers when CPU usage climbs. Shopping cart data is stored in a shared database or cache rather than on individual servers, so it does not matter which server a customer reaches. Only the load balancer is exposed to the internet, while the servers accept traffic solely from it.

Best practices

  • Configure meaningful health checks that test whether the app actually works, not just whether the server responds.
  • Spread servers across multiple availability zones for resilience.
  • Store sessions in a shared cache or database so any server can handle any request.
  • Allow traffic to backend servers only from the load balancer.

Common mistakes

  • Making the load balancer the only redundant part while relying on a single database.
  • Depending on sticky sessions so heavily that one server ends up overloaded.
  • Leaving backend servers directly reachable from the internet, bypassing the load balancer and its protections.

Frequently asked questions

Do I need a load balancer for my website?

Not always. A small site on one server, or one hosted on a managed platform or CDN, may not need a separate load balancer. It becomes valuable when you need high availability, run more than one server, expect traffic spikes, or want zero-downtime deployments for an important application.

What is the difference between a load balancer and a CDN?

A CDN caches and serves content from many locations close to users, reducing distance and load on your servers. A load balancer distributes requests among your own servers in one or more locations. Many sites use both: the CDN in front for caching and protection, the load balancer behind it.

Can a load balancer protect against DDoS attacks?

It helps absorb moderate traffic increases by spreading load and can be paired with a WAF and rate limiting. Large DDoS attacks, however, need dedicated mitigation from a CDN or cloud provider with enough network capacity. A load balancer is part of a resilient setup, not a complete DDoS defense.

Need help with this?

Cloud y DevOps by VYZEON — Infraestructura que escala, despliega y se recupera por sí sola.

Fixed packages from $199. Written scope, no surprises.

See Cloud y DevOps

Related terms

More Security & cloud terms