The Computing Series

The Concept

A load balancer sits between clients and a pool of servers. It receives every incoming request and forwards it to one server in the pool. The forwarding decision is the load balancing algorithm.

Layer 4 load balancing (transport layer): decisions are made based on IP addresses and TCP/UDP ports. The load balancer does not inspect the request content — it routes packets. Fast, low overhead, but cannot make content-aware decisions.

Layer 7 load balancing (application layer): decisions are made based on HTTP headers, URL paths, cookies, or request content. Slower than Layer 4 but enables routing based on request type: /api requests go to one pool, /static requests go to another.

The choice between Layer 4 and Layer 7 is AT6 — Generality vs. Specialisation. Layer 4 is general and fast. Layer 7 is specialised and flexible.


Read in the book →