# Load Balancing — System Design

Source: https://www.geekswithgeeks.com/en/system-design/sd-load-balancing

> Spreading traffic across servers for scale and failover.

## Why load balance

A load balancer sits in front of a pool of identical servers, routing each request to a healthy one. It enables **horizontal scaling** and hides individual failures.

## Algorithms

**Round robin** (simple), **least connections** (uneven request cost), **consistent hashing** (sticky routing to the same node — useful for caches).

## L4 vs L7

L4 balances by IP/port (fast, dumb). L7 reads HTTP — can route by path, host, or cookie, do TLS termination and retries.

## Avoid a single point of failure

The load balancer itself must be redundant — run a pair with a floating IP or DNS failover so it can't take down the whole system.
