Skip to content
StackDecode
System Design
8. Load Balancing and ScalabilityAnimated

Layer 4 Load Balancing

Balancing by IP and port.

The idea

Works at the transport layer, forwarding TCP or UDP without reading the request. Very fast.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

ClientL4 balancerServer AServer B
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

A layer 4 balancer looks only at IP addresses and TCP ports.

step:
1/3
at:
Client
1/7

The green dot is a request moving through the system.

Step by step

  1. 1Packet arrives at the balancer
  2. 2It picks a backend by IP and port
  3. 3It forwards the connection
  4. 4Replies return the same way

Where it is used

High throughput TCP traffic.

Watch out for

It cannot route by URL or headers.

Related