0
0
HLDsystem_design~7 mins

Why load balancers distribute traffic in HLD - Why This Architecture

Choose your learning style9 modes available
Problem Statement
When a single server handles all incoming requests, it quickly becomes overwhelmed, causing slow responses and potential crashes. This creates a bottleneck where users experience delays or service outages, especially during traffic spikes.
Solution
Load balancers spread incoming requests across multiple servers to prevent any one server from becoming overloaded. They monitor server health and distribute traffic efficiently, ensuring smooth and reliable service even under high load.
Architecture
Clients
Clients
Load Balancer
Load Balancer
Server 1

This diagram shows clients sending requests to a load balancer, which then distributes the requests evenly across multiple servers to balance the load.

Trade-offs
✓ Pros
Prevents any single server from becoming a bottleneck by distributing traffic evenly.
Improves system availability by routing traffic away from unhealthy servers.
Enables horizontal scaling by adding more servers behind the load balancer.
Enhances fault tolerance and reduces downtime.
✗ Cons
Introduces an additional network hop which can add slight latency.
Load balancer itself can become a single point of failure if not redundant.
Requires configuration and monitoring to ensure proper traffic distribution.
Use when your system handles more than a few hundred requests per second or when you need high availability and fault tolerance.
Avoid if your traffic is very low (under 100 requests per second) and your system is simple, as the added complexity may not justify the benefits.
Real World Examples
Netflix
Uses load balancers to route streaming requests to multiple edge servers, ensuring smooth playback and avoiding overload on any single server.
Amazon
Distributes incoming shopping requests across many servers to handle massive traffic spikes during sales events without downtime.
Uber
Balances ride requests across multiple backend servers to maintain fast response times and system reliability.
Alternatives
Client-side Load Balancing
Clients decide which server to send requests to, rather than a centralized load balancer.
Use when: Choose when you want to reduce load balancer complexity and clients can maintain an updated list of servers.
DNS Load Balancing
Uses DNS to distribute traffic by returning different server IPs to clients.
Use when: Choose when you want a simple, low-cost solution but can tolerate DNS caching delays.
Summary
Load balancers prevent servers from becoming overwhelmed by spreading traffic evenly.
They improve system reliability and scalability by managing request distribution and server health.
Using load balancers is essential for systems expecting moderate to high traffic volumes.