QA
Beginner LevelSystem Design & Architecture

How do Load Balancers distribute traffic (Round Robin, Least Connections, IP Hash)?

❓ Interview Prompt: Explain Load Balancing layer 4 (TCP/UDP) vs layer 7 (HTTP), Round Robin, Least Connections, Weighted Round Robin, and IP Hash algorithms.

A Load Balancer acts as a reverse proxy traffic cop, routing incoming client requests across a pool of backend servers:

Load Balancing Algorithms:

β€’
Round Robin: Routes requests sequentially across the server pool ($S_1 \rightarrow S_2 \rightarrow S_3 \rightarrow S_1$).
β€’
Least Connections: Directs new traffic to the server with the fewest active connection sockets (ideal for long-lived HTTP/WebSocket sessions).
β€’
Weighted Round Robin: Assigns higher traffic ratios to more powerful server instances.
β€’
IP Hash: Hashes the client IP address to route the user to the same server consistently (Sticky Sessions).

Code Implementation Example

markdown
Load Balancer Architecture Flow:

[Clients] ──> [Layer 7 Load Balancer (NGINX/HAProxy)]
                     β”œβ”€β”€> [Server Node 1 (Active: 10)]
                     β”œβ”€β”€> [Server Node 2 (Active: 3)]  <-- Least Connections Route!
                     └──> [Server Node 3 (Active: 12)]
πŸ’‘Load Balancer distributing requests using Least Connections.
🎯 Interview Key Takeaway

Use Layer 7 Load Balancers with Least Connections or Weighted Round Robin to distribute traffic evenly across server pools.

#System Design#Load Balancing#Algorithms#Layer 7#Beginner
Back to all System Design & Architecture Questions→

More System Design & Architecture Interview Questions

Beginner LevelSystem Design & Architecture

Explain the CAP Theorem and PACELC Theorem with real-world database examples.

Beginner LevelSystem Design & Architecture

What is Vertical Scaling (Scale Up) vs Horizontal Scaling (Scale Out)?

Beginner LevelSystem Design & Architecture

What is a Content Delivery Network (CDN) and how does Edge Caching reduce latency?