SystemExpertsSystemExperts
Pricing

Patterns

35 items

Horizontal Scaling Pattern

15mbeginner

Retry with Backoff Pattern

15mbeginner

Replication Pattern

25mintermediate

Caching Strategies Pattern

25mintermediate

Persistent Connections Pattern

20mintermediate

Load Balancing Pattern

20mintermediate

Fan-out Pattern

20mintermediate

Fan-in Pattern

20mintermediate

Circuit Breaker Pattern

20mintermediate

Eventual Consistency Pattern

25mintermediate

Queue-based Load Leveling Pattern

20mintermediate

Bloom Filters Pattern

20mintermediate

Time-Series Storage Pattern

20mintermediate

Bulkhead Pattern

20mintermediate

Batch Processing Pattern

20mintermediate

Write-Ahead Log Pattern

20mintermediate

API Gateway Pattern

20mintermediate

Backend for Frontend Pattern

20mintermediate

Sidecar Pattern

20mintermediate

Idempotency Pattern

20mintermediate

Rate Limiting Pattern

20mintermediate

Backpressure Pattern

20mintermediate

Pub/Sub Pattern

25mintermediate

Strong Consistency Pattern

30madvanced

Conflict Resolution Pattern

25madvanced

Leader Election Pattern

25madvanced

Consensus Protocols Pattern

30madvanced

CQRS Pattern

28madvanced

LSM Trees Pattern

25madvanced

Sharding Pattern

25madvanced

Event Sourcing Pattern

30madvanced

Stream Processing Pattern

25madvanced

Change Data Capture Pattern

25madvanced

Distributed Locking Pattern

25madvanced

Two-Phase Commit Pattern

25madvanced
System Design Pattern
Scalabilityload-balancinground-robinconsistent-hashinghealth-checksl4-l7intermediate

Load Balancing Pattern

Distributing traffic across multiple servers

Used in: API Gateway, Nginx, HAProxy|20 min read

Summary

Load balancing distributes incoming traffic across multiple servers to prevent any single server from becoming overwhelmed. Load balancers use algorithms like Round Robin (simple rotation), Least Connections (route to least busy), Weighted (proportional to capacity), and IP Hash (sticky sessions). Modern load balancers also perform health checks, SSL termination, and can route based on content. This pattern is fundamental to horizontal scaling - without load balancing, you cannot utilize multiple servers effectively. Every production system uses load balancing, from simple DNS round-robin to sophisticated L7 application load balancers.

Key Takeaways

Even Distribution is Key

Goal is to spread load evenly so no server is overwhelmed while others are idle. Uneven distribution wastes capacity and creates bottlenecks.

Health Checks Prevent Failures

Load balancer must detect unhealthy servers and stop sending traffic. Without health checks, requests go to dead servers and fail.

L4 vs L7 Load Balancing

L4 (transport) routes based on IP/port - fast, simple. L7 (application) routes based on HTTP content - flexible, can route by URL, headers, cookies.

Round Robin: Rotate through servers sequentially - Simple, fair distribution - Does not account for server capacity or current load

Least Connections: Route to server with fewest active connections - Better for varying request durations - Requires connection tracking

Weighted: Route proportionally to server capacity - Server with weight 2 gets 2x traffic of weight 1 - Good for mixed-capacity fleet

IP Hash: Hash client IP to determine server - Same client always goes to same server - Provides sticky sessions without cookies

Least Response Time: Route to fastest responding server - Optimizes for latency - Requires latency monitoring

Load Balancing Algorithms

Summary

Load balancing distributes incoming traffic across multiple servers to prevent any single server from becoming overwhelmed. Load balancers use algorithms like Round Robin (simple rotation), Least Connections (route to least busy), Weighted (proportional to capacity), and IP Hash (sticky sessions). Modern load balancers also perform health checks, SSL termination, and can route based on content. This pattern is fundamental to horizontal scaling - without load balancing, you cannot utilize multiple servers effectively. Every production system uses load balancing, from simple DNS round-robin to sophisticated L7 application load balancers.

Key Takeaways

Even Distribution is Key

Goal is to spread load evenly so no server is overwhelmed while others are idle. Uneven distribution wastes capacity and creates bottlenecks.

Health Checks Prevent Failures

Load balancer must detect unhealthy servers and stop sending traffic. Without health checks, requests go to dead servers and fail.

L4 vs L7 Load Balancing

L4 (transport) routes based on IP/port - fast, simple. L7 (application) routes based on HTTP content - flexible, can route by URL, headers, cookies.

Sticky Sessions Trade-offs

Sticky sessions route same client to same server - required for stateful apps. But reduces load distribution and complicates failover.

SSL Termination

Load balancer can terminate SSL, sending unencrypted traffic to backends. Offloads crypto from servers, simplifies certificate management.

Geographic Load Balancing

DNS-based load balancing routes users to nearest datacenter. Reduces latency, enables disaster recovery, complies with data locality requirements.

Pattern Details

Round Robin: Rotate through servers sequentially - Simple, fair distribution - Does not account for server capacity or current load

Least Connections: Route to server with fewest active connections - Better for varying request durations - Requires connection tracking

Weighted: Route proportionally to server capacity - Server with weight 2 gets 2x traffic of weight 1 - Good for mixed-capacity fleet

IP Hash: Hash client IP to determine server - Same client always goes to same server - Provides sticky sessions without cookies

Least Response Time: Route to fastest responding server - Optimizes for latency - Requires latency monitoring

Load Balancing Algorithms

Trade-offs

AspectAdvantageDisadvantage

Premium Content

Sign in to access this content or upgrade for full access.