DEV Community

Cover image for Load Balancer in System Design – Part 1: Introduction & Fundamentals
ZeeshanAli-0704
ZeeshanAli-0704

Posted on • Edited on

Load Balancer in System Design – Part 1: Introduction & Fundamentals

πŸŒ€ Load Balancer in System Design – Part 1: Introduction & Fundamentals

πŸ“‘ Table of Contents

  1. What is a Load Balancer?
  2. Why Use a Load Balancer?
  3. What Does Load Balancing Actually Do?
  4. Layer 4 vs Layer 7 Load Balancing
  5. Real World Examples of Load Balancers
  6. Conclusion

πŸ”Ή What is a Load Balancer?

A load balancer is a system design component that distributes incoming traffic across multiple servers, ensuring no single server is overloaded.

Think of it as a traffic cop standing at the intersection of your application:

  • It takes every incoming request (cars).
  • Redirects them to the correct server (roads).
  • Ensures smooth flow without jams.

πŸ’‘ Key Idea: The main purpose of a load balancer is to provide high availability, fault tolerance, and better performance.

πŸ“Œ Example:
Imagine an e-commerce app during a sale. Instead of sending all users to one server (which will crash), the load balancer distributes them across multiple servers, ensuring the site stays up.


πŸ”Ή Why Use a Load Balancer?

βœ… Increased Availability and Reliability

  • By spreading traffic across multiple servers, the system avoids single point of failure.
  • If Server A goes down, requests are automatically redirected to Server B or C.

πŸ’‘ Real-world Example: Netflix uses global load balancers to reroute traffic if a regional server cluster goes down, so users rarely notice outages.


βœ… Improved Performance

  • Prevents any single server from becoming overloaded.
  • Ensures fast response times by spreading requests evenly.

πŸ“Œ Practical Use: Banking systems route requests like "Check Balance" and "Fund Transfer" across different app servers, reducing delays during peak hours (e.g., salary days).


βœ… Scalability

  • As demand grows, you can add new servers to the pool.
  • Load balancers automatically start sending traffic to them without downtime.

πŸ“Œ Example: During Black Friday, Amazon temporarily adds new servers to handle traffic spikes, balanced automatically by AWS Elastic Load Balancers.


βœ… Maintenance

  • Servers can be updated, patched, or restarted without downtime.
  • Load balancers reroute traffic to healthy servers while maintenance happens.

πŸ’‘ Use Case: Software companies roll out updates to one server at a time, keeping the system online throughout.


πŸ”Ή What Does Load Balancing Actually Do?

A load balancer performs 3 key jobs:

  1. Distributes Requests Evenly
  • Prevents overloading any single server.
  1. Detects Failures
  • Monitors servers using health checks (ping, HTTP status).
  • Redirects traffic away from failed servers.
  1. Optimizes User Experience
  • Directs requests to the least busy or fastest server.

πŸ“Œ Simple Example Flow:

User β†’ Load Balancer β†’ {Server A, Server B, Server C}
Enter fullscreen mode Exit fullscreen mode

If Server A is overloaded:

Next request β†’ Server B (because it's free)
Enter fullscreen mode Exit fullscreen mode

This makes the system resilient, fast, and highly available.


πŸ”Ή Layer 4 vs. Layer 7 Load Balancing

Load balancers operate at different OSI layers:

⚑ Layer 4 (Transport Layer)

  • Works with TCP/UDP connections.
  • Routes requests based on IP + Port.
  • Faster but less flexible.
  • Can’t inspect HTTP headers or payload.

πŸ“Œ Example: A gaming server balancing raw TCP connections between players.


🌐 Layer 7 (Application Layer)

  • Works at application level (HTTP/HTTPS, gRPC, WebSockets).
  • Can make routing decisions based on:

    • HTTP headers
    • Cookies
    • Request paths (/images vs /api)
  • More flexible but slightly slower.

πŸ“Œ Example:

  • /videos/* requests β†’ Video server cluster.
  • /api/* requests β†’ API server cluster.

πŸ’‘ Real-World Use: YouTube uses Layer 7 load balancers to route video streaming requests vs. API calls differently.


πŸ”Ή Real World Examples of Load Balancers

Let’s see how major companies use them:

  1. Amazon (E-commerce)
  • Uses AWS Elastic Load Balancer to distribute millions of checkout and search requests.
  • Ensures scaling during festive sales.
  1. Netflix (Streaming)
  • Uses global load balancing + regional failover.
  • If EU servers fail, traffic reroutes to US clusters.
  1. Banking Apps
  • Internal load balancers distribute traffic across multiple app servers.
  • Transactions are routed to the least loaded server for speed.
  1. Gaming Servers
  • Online multiplayer games (e.g., PUBG, Fortnite) rely on load balancers to match players with the nearest, least-lag server.

πŸ“Œ Diagram Reference:
(You could add a simple diagram like below when publishing)

[ Users ]  
   ↓  
[ Load Balancer ]  
   ↓ ↓ ↓  
[ Server A | Server B | Server C ]
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Conclusion

In this part, we covered the fundamentals of load balancing:

  • What a load balancer is and why it matters.
  • How it improves availability, reliability, scalability, and performance.
  • Layer 4 vs. Layer 7 differences.
  • Real-world examples from Amazon, Netflix, banks, and gaming.

πŸ‘‰ In Part 2, we’ll dive into the Types of Load Balancers (Hardware, Software, Cloud-based), with deeper analysis of their advantages, challenges, and best-fit use cases.


More Details:

Get all articles related to system design
Hastag: SystemDesignWithZeeshanAli

systemdesignwithzeeshanali

Git: https://github.com/ZeeshanAli-0704/SystemDesignWithZeeshanAli

Top comments (0)