Network security

What Is a Load Balancer? How Traffic Distribution Works

A load balancer is the traffic controller in front of your servers. Here is how it works, which type to pick, and what it costs on AWS.

Cysoro Security TeamPublished · 8 min read
NETWORK SECURITY Loadbalancer One entry point. Many healthy servers. BALANCERServer 1Server 2Server 3◉
Quick answer

A load balancer is a device or software service that sits in front of a group of servers and distributes incoming network traffic across them. It checks server health, sends each request to a healthy server using a chosen algorithm, and keeps your site or app available when traffic spikes or a server fails.

Key takeaways

  • A load balancer spreads traffic across healthy servers so one failure or traffic spike does not take your service down.
  • Layer 4 load balancers route by IP and port; Layer 7 load balancers route by URL, headers, and cookies.
  • Cloud load balancers start at about $16 a month before traffic on AWS, and most small sites only need one when they run two or more servers.

One server can only handle so much. When traffic grows, when a server crashes, or when you need to update without downtime, a single machine becomes a single point of failure. A load balancer fixes that by spreading the work.

What is a load balancer?

A load balancer is a device or software service that distributes incoming network traffic across a group of servers, called a server pool. It sits between visitors and your servers, so visitors connect to the load balancer instead of to one server directly.

Its two jobs are simple. First, spread requests so no server is overloaded. Second, send traffic only to healthy servers. If a server fails or is taken offline for maintenance, the load balancer redirects traffic to the servers that are still working.

You can think of it as a receptionist for a busy office. Callers reach one number, and the receptionist sends each call to a free member of staff. The caller does not need to know who answered, and the office keeps working even if one person is away.

How a load balancer sits between visitors and serversVisitorsbrowsers and appsLoad balancerhealth checksServer 1Server 2Server 3 — downTraffic goes only to healthy servers. A failed server is skipped automatically.
Visitors reach one address; the load balancer forwards each request to a healthy server. Illustration by Cysoro.

How does a load balancer work?

A load balancer follows the same cycle for every request: receive it, pick a healthy server using its algorithm, forward it, and return the response. It repeats health checks in the background, usually every few seconds.

  1. A visitor connects. The visitor reaches the load balancer's address, often a virtual IP or a cloud hostname, not an individual server.
  2. The load balancer picks a server. It applies its algorithm, such as round robin or least connections, and considers current load and health.
  3. The server answers. The chosen server processes the request and sends the response back, usually through the load balancer.
  4. Health checks run continuously. The load balancer probes each server, for example with an HTTP request to a health page, and removes any server that stops responding.

Health checks are the feature that turns several servers into a resilient system. Without them, a balancer could keep sending visitors to a dead server. With them, a failure becomes a brief, automatic reroute.

Many load balancers also terminate TLS, which means they handle encryption and decryption. That offloads work from your servers and gives you one place to manage certificates. You can check whether your own site's certificate is valid with our free SSL checker.

What are the main types of load balancer?

The main types are hardware, software, cloud, and DNS load balancers. They differ in where they run and how much you manage, but they all distribute traffic across a server pool.

TypeWhat it isBest forDrawback
HardwareA dedicated physical appliance, such as F5 BIG-IPLarge data centers needing high throughputHigh upfront cost and manual scaling
SoftwareSoftware such as NGINX or HAProxy on a serverFlexible, low-cost setups you controlYou manage updates and availability
CloudA managed service such as AWS ELB or Google Cloud Load BalancingMost cloud apps; scales automaticallyHourly and traffic charges add up
DNSDNS answers return different server IPsSpreading traffic across regionsSlow failover; no real health awareness
GlobalRoutes users to the nearest healthy regionWorldwide apps needing low latencyMore complex to configure and test

For most small teams, the choice is between a software balancer and a cloud one. Software gives you control and low cost. Cloud gives you managed scaling and less maintenance, at a predictable hourly price.

Layer 4 vs Layer 7: what is the difference?

Layer 4 and Layer 7 describe where in the OSI model the balancer makes its decision. Layer 4 uses transport information; Layer 7 reads application data. That difference decides how smart the routing can be.

Layer 4 load balancers

A Layer 4 balancer routes by IP address and TCP or UDP port. It does not inspect the content of the request, so it is fast and works for any TCP or UDP traffic, including databases and game servers.

AWS calls this a Network Load Balancer. It is a good choice when you need very high throughput, low latency, or traffic that is not HTTP.

Layer 7 load balancers

A Layer 7 balancer reads HTTP data such as the URL, host, headers, and cookies. It can send /images to one pool and /api to another, or route users by cookie for session persistence.

AWS calls this an Application Load Balancer. It is the usual choice for websites and web APIs, because content-based routing and TLS termination are built in. If you run a public website, start here.

Which load balancing algorithm should you use?

The algorithm is the rule the balancer uses to pick a server. The right choice depends on whether your servers are equal, whether requests take similar time, and whether users must return to the same server.

  • Round robin: sends requests to servers in turn. Simple and fair when servers are equal and requests are similar.
  • Weighted round robin: gives stronger servers a larger share. Use it when servers have different capacity.
  • Least connections: sends new requests to the server with the fewest active connections. Best when requests vary in length.
  • Least response time: picks the server that has answered fastest recently. Good when latency matters most.
  • IP hash: hashes the visitor's IP to pick a server, so the same visitor usually reaches the same server. Useful for simple session persistence.

For most web apps, least connections is a safe default. Round robin is fine for identical servers with short, similar requests. Avoid IP hash unless you have a clear reason, because one busy network can overload a single server.

What are the benefits of a load balancer?

The main benefits are availability, scalability, and easier maintenance. Together they let you grow and update a service without planned downtime for visitors.

  • High availability: if one server fails, traffic moves to the others automatically.
  • Scalability: add servers to the pool when traffic grows, and remove them when it falls.
  • Zero-downtime updates: take one server out, update it, and put it back while the rest serve traffic.
  • Better performance: no single server carries the whole load, so response times stay steadier.
  • Security: servers stay private behind the balancer, which can also terminate TLS and filter traffic.

There is a trade-off. A load balancer is itself a component that can fail, so production setups usually run two in an active-passive pair. Cloud providers handle that redundancy for you in their managed services.

Layer 4 vs Layer 7 at a glanceLayer 4 — transportRoutes by IP address and portDoes not read request contentVery fast, works for any TCP/UDPExample: AWS Network Load BalancerLayer 7 — applicationRoutes by URL, host, header, cookieCan terminate TLS and inspect HTTPSmarter routing, slightly slowerExample: AWS Application Load Balancer
Layer 4 is faster and protocol-agnostic; Layer 7 is smarter for web traffic. Illustration by Cysoro.

When do you need a load balancer?

You need one when a single server is a risk to your business: when downtime costs money, when traffic is unpredictable, or when you update often. If none of those apply, you probably do not need one yet.

Common signs include traffic spikes that slow or crash your site, a server failure that took you offline, plans to run your app in two availability zones, or a need to deploy without maintenance windows. A network security audit can also reveal single points of failure like this.

If you only need to serve a small site, a content delivery network and good caching may help more, for less money. Add a balancer when you add a second server, not before.

How much does a load balancer cost?

Cloud load balancers usually cost an hourly fee plus a charge for the traffic they handle. On AWS in US East, an Application or Network Load Balancer costs $0.0225 per hour, about $16.43 a month, before any traffic charges.

Traffic charges depend on the type. An Application Load Balancer adds $0.008 per Load Balancer Capacity Unit hour, while a Network Load Balancer adds $0.006 per unit hour. A small site with modest traffic often pays roughly $20 to $30 a month in total.

Open-source balancers such as HAProxy and NGINX have no software license cost, but you still pay for the server they run on and the time to maintain them. Cloudflare and other providers include basic load balancing in some paid plans, so compare the full bundle before choosing.

How do you secure a load balancer?

A load balancer is a public entry point, so secure it like one. Keep backend servers private, use TLS, and limit who can change the configuration. A misconfigured balancer can expose internal services.

  • Put backends in private subnets so only the balancer can reach them directly.
  • Use TLS everywhere and redirect HTTP to HTTPS. Check your headers with our free security headers checker.
  • Restrict the management console with MFA and least-privilege access.
  • Log balancer traffic and alert on unusual spikes, failed health checks, or 5xx errors.
  • Keep software updated if you run your own balancer, and patch promptly.

Also review what your balancer exposes. Health check pages should return a simple status, not version numbers or internal details. For APIs behind a balancer, see our guide to API security tools.

What mistakes should you avoid?

The most common mistakes are running a single balancer with no redundancy, forgetting health checks, and using sticky sessions to hide a design problem. Each one quietly removes the benefit you paid for.

Other mistakes include sending all traffic to one availability zone, ignoring balancer logs until an outage, and choosing Layer 7 routing for non-HTTP traffic that needs Layer 4 speed. Test failover before you need it: stop one server and confirm traffic moves cleanly.

Test your failoverSchedule a short test each quarter: stop one backend server and watch the balancer reroute traffic. If visitors see errors, fix the health check or timeout settings before a real failure finds the gap.

The bottom line

A load balancer is a simple idea with a large payoff: spread traffic across healthy servers, and your service survives failures and spikes that would sink a single machine. Pick Layer 7 for websites and APIs, Layer 4 for raw TCP and UDP speed.

Start small, use health checks, and test failover regularly. You can check the public side of your setup in minutes with the free SSL checker from Cysoro.

For the underlying concepts, LoadBalancer.org explains how load balancers work, and AWS publishes its Elastic Load Balancing prices.

Frequently asked questions

What is a load balancer in simple terms?

It is a traffic controller for your servers. Visitors connect to the load balancer, and it forwards each request to a healthy server that can answer it, instead of letting one server handle everything.

What is the difference between Layer 4 and Layer 7 load balancing?

Layer 4 works at the transport layer and routes by IP address and port, without reading the request content. Layer 7 works at the application layer and can route by URL, host, headers, or cookies, which allows smarter decisions.

Do I need a load balancer for a small website?

Not usually. A single well-sized server or a managed hosting plan is enough for most small sites. You need a load balancer when you run two or more servers, need high availability, or expect traffic spikes.

What happens if a server behind a load balancer fails?

The load balancer stops sending traffic to it after health checks fail. Requests go to the remaining healthy servers, so visitors usually notice nothing except possibly slower responses under heavy load.

Is a load balancer the same as a reverse proxy?

No, although they overlap. A reverse proxy forwards requests to backend servers and can cache or rewrite them. A load balancer focuses on distributing traffic across a pool of servers and checking their health.

What is session persistence in load balancing?

Session persistence, also called sticky sessions, sends requests from the same user to the same server. It helps when an app stores session data locally, but it can unbalance traffic, so shared session storage is usually better.

How much does a load balancer cost?

Cloud load balancers are usually billed by the hour plus traffic. On AWS, an Application or Network Load Balancer costs about $0.0225 per hour, or about $16.43 a month before traffic, in US East. Open-source options such as HAProxy and NGINX cost nothing for the software itself.

Sources

  1. LoadBalancer.org — What is a load balancer? The complete beginner's guide
  2. AWS — Elastic Load Balancing pricing
  3. Cloudflare — What is load balancing?
  4. NGINX — What is load balancing?
  5. Site24x7 — Load Balancer Guide: Types, Algorithms and Best Practices
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against LoadBalancer.org, AWS Elastic Load Balancing pricing, Cloudflare, and NGINX load balancing documentation.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free