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

IP Hashing

Hash the client IP to choose a server.

The idea

The same client always reaches the same server, giving simple stickiness without cookies.

Watch it work

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

10.0.0.4Load balancerServer 11 totalServer 20 totalServer 30 total
  • chosen path
  • active connections (bar)

Request 1 goes to server 1: hash of 10.0.0.4 always maps to this server, so a client sticks to one server.

request:
1
server:
1
1/14

The white bar inside each server is its current number of active connections.

Step by step

  1. 1Hash the client IP
  2. 2Map the hash to a server
  3. 3Always route that client there
  4. 4Rehash when servers change

Where it is used

Simple session affinity.

Watch out for

Clients behind one NAT all land on one server.

Related