DEV Community

Karam Khoury
Karam Khoury

Posted on

System Design: The 6 Core Load Balancing Algorithms, Explained

Stop guessing how your traffic scales — understand the routing mechanics. Here's how the six core algorithms actually dictate traffic distribution, and when to reach for each.

1. Round Robin

Distributes requests sequentially across the server pool.

Example: Dealing a deck of cards — Server A gets request 1, Server B gets 2, Server C gets 3, then the cycle repeats. Best for identical, stateless servers.

2. Weighted Round Robin

Sequential routing that accounts for unequal hardware.

Example: Server A has 64 GB RAM, Server B has 32 GB. Assign weight 2 to A and 1 to B, and A receives exactly twice as many requests.

3. Least Connections

Routes traffic to the server with the fewest active, open sessions.

Example: Joining the supermarket checkout with the fewest people. Ideal for long-lived connections — WebSockets, heavy database queries.

4. IP Hash

Uses a hash of the client's IP to guarantee the same client hits the same server every time.

Example: A user at 192.168.1.50 is always routed to Server C. Mandatory for legacy stateful apps that store session data in-memory rather than a distributed cache.

5. Least Response Time

A hybrid: lowest number of active connections combined with the lowest average response time.

Example: Joining the line that has both the fewest people and the fastest cashier. Essential when server performance degrades unpredictably.

6. Adaptive (Resource-Based)

Routes based on real-time hardware telemetry from an agent on each server.

Example: The load balancer queries CPU, memory, and I/O wait in real time, and avoids any server spiking above 80% utilization.

Takeaway

Choose your algorithm based on your infrastructure and state management — not trends. Build systems that scale predictably.

Written by Karam Khoury — Lead Software Engineer (.NET & Azure), building secure, scalable fintech systems. More at karamkhoury.me.

Top comments (0)