Learn/Glossary/Load Balancer
Infrastructure

Load Balancer

A load balancer acts as a traffic cop, distributing incoming requests across a group of backend servers to prevent overload.

Diagram

          ┌─────────────┐
          │   Client    │
          └──────┬──────┘
                 │  Requests
                 ▼
          ┌─────────────┐
          │ Load Balancer│  (Routes traffic)
          └──┬─────┬─┬──┘
             │     │ │
             ▼     ▼ ▼
          ┌──┐   ┌──┐ ┌──┐
          │S1│   │S2│ │S3│  (Backend servers)
          └──┘   └──┘ └──┘

In Depth

A Load Balancer is a server that sits between incoming user traffic and a pool of backend servers, routing each request to one server to balance the workload.

Code Example

Nginx load balancing configuration

upstream backend_servers {
  server 10.0.0.1:8080;
  server 10.0.0.2:8080;
  server 10.0.0.3:8080;
}

server {
  listen 80;
  location / {
    proxy_pass http://backend_servers;
  }
}

Related Terms