Skip to content

Load balancing

Also called: load balancer

Published:

How does load balancing work?

A load balancer distributes incoming network traffic across a pool of resources that support an application [1]. An algorithm decides where each request goes. Static algorithms ignore the current state of the servers: round robin takes them in turn, weighted round robin sends more traffic to servers with higher weights, and IP hash picks a server from the client's IP address. Dynamic algorithms look at live state; least connection sends the request to the server with the fewest active connections [1]. Load balancers also run health checks, spotting a failing server and redirecting traffic to healthy ones [1].

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

It comes down to how much of the request the balancer reads. On Google Cloud, Application Load Balancers are proxy-based Layer 7 balancers suited to HTTP and HTTPS, and they can route on details such as HTTP headers and URIs [2]. Network Load Balancers work at Layer 4 and handle TCP, UDP and other IP protocol traffic [2]. Scope varies too: a global load balancer supports backends in multiple regions, a regional one supports backends in a single region [2].

What does load balancing buy you?

Picture an online shop spreading sale-day traffic across three servers. If one fails, the load balancer routes around it to the other two, and the same mechanism lets you take a server down for maintenance without an outage [1]. AWS also credits load balancing with preventing bottlenecks, making it easy to add or remove servers as demand changes, and helping mitigate DDoS attacks [1].

Frequently asked questions

Is a load balancer hardware or software?

Either. AWS classifies load balancers as hardware or software, and cloud providers also offer load balancing as a managed service.

Sources

  1. What is Load Balancing? — Amazon Web Services
  2. Cloud Load Balancing overview — Google Cloud Documentation

Related terms