Load Balancing

Overview

Load balancing distributes incoming traffic across multiple healthy backend instances to improve availability and responsiveness.

Load Balancing Algorithms

flowchart LR C[Client Requests] --> LB[Load Balancer] LB --> A[App Instance A] LB --> B[App Instance B] LB --> D[App Instance C]

Production Example

A global API usually combines DNS-based routing with regional load balancers.

upstream api_pool { least_conn; server api-1.internal:8080; server api-2.internal:8080; server api-3.internal:8080; } server { listen 80; location / { proxy_pass http://api_pool; } }

Health and Resilience

Common Pitfalls

Key Takeaways