Skip to content

Load Balancer

In one line

A load balancer distributes incoming network traffic across multiple servers to ensure reliability and performance.

In simple words

A load balancer sits in front of your servers and distributes incoming requests across them. If you have 3 web servers, the load balancer sends each new request to a different server, spreading the load evenly.

Load balancers improve availability — if one server fails, the load balancer stops sending traffic to it and routes to the healthy servers. They also improve performance — by spreading requests, no single server gets overwhelmed.

There are two main types: Layer 4 (transport layer — distributes based on IP and port) and Layer 7 (application layer — can route based on HTTP path, headers, cookies). Common algorithms are round-robin, least connections, and IP hash.

Example

yaml
apiVersion: v1
kind: Service
metadata:
  name: my-app-lb
spec:
  type: LoadBalancer
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 8080

This Kubernetes Service of type LoadBalancer provisions a cloud load balancer that distributes traffic to the Pods.

How it works

  1. A client sends a request to the load balancer's address.
  2. The load balancer picks a healthy backend server using an algorithm.
  3. It forwards the request to that server.
  4. The server's response goes back through the load balancer to the client.

Common confusions

  • Confused with: Reverse Proxy

    The difference: A load balancer distributes traffic across servers; a reverse proxy sits in front of servers and can also handle caching, TLS, and routing. Many load balancers also act as reverse proxies.

Related terms

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary