← Back to Learn
Beginner18 April 20263 min read

Load Balancing — Explained Like You're Ordering Food

Ever wondered how Netflix handles millions of users at once without crashing? The secret is Load Balancing. Let's understand it with a simple restaurant analogy.

load-balancingscalabilitybasics

What is Load Balancing?

Imagine you walk into a restaurant with 5 billing counters. If everyone stands in one line at Counter 1, the wait is terrible — even though Counters 2-5 are empty.

A Load Balancer is like a smart manager who says: *"You go to Counter 2, you go to Counter 4"* — distributing customers evenly so no single counter is overwhelmed.

In tech terms, a Load Balancer distributes incoming network traffic across multiple servers so that no single server bears too much load.

Why Do We Need It?

Without load balancing:

  • • One server gets all the traffic and crashes
  • • Users see "503 Service Unavailable"
  • • Your app goes down during peak hours
  • With load balancing:

  • • Traffic is spread across multiple servers
  • • If one server dies, others handle the load
  • • Users get fast, reliable responses
  • Real-World Example: How Swiggy Handles Orders

    When you open Swiggy during lunch hour, millions of people are browsing restaurants simultaneously. Swiggy doesn't run on one server — they have hundreds.

    A load balancer sits in front and routes your request to whichever server is least busy. You get your restaurant list in milliseconds, and you never know which server actually served you.

    Types of Load Balancing

    1. Round Robin

    The simplest approach. Requests go to servers in order: Server 1 → Server 2 → Server 3 → Server 1 → ...

    Like: A teacher assigning homework to students one by one in a circle.

    2. Least Connections

    Send the request to whichever server currently has the fewest active connections.

    Like: At a bank, you go to the teller with the shortest queue.

    3. IP Hash

    The client's IP address determines which server they go to. Same user always hits the same server.

    Like: Your regular barber — you always go to the same one.

    4. Weighted Round Robin

    Some servers are more powerful than others. Give more traffic to stronger servers.

    Like: In cricket, you give more overs to your best bowler.

    Where Does the Load Balancer Sit?

    
    

    Users → Load Balancer → [Server 1, Server 2, Server 3]

    
    
    

    The load balancer is the entry point. Users never talk to servers directly — they only talk to the load balancer, which forwards the request.

    Popular Load Balancers

  • Nginx — Very popular, open source
  • AWS ELB (Elastic Load Balancer) — Managed by AWS
  • HAProxy — High performance, used by GitHub
  • Cloudflare — CDN + Load Balancing
  • Key Takeaway

    Load Balancing = Don't put all eggs in one basket. Spread the traffic, keep things fast, and if one server fails, others pick up the slack.

    It's one of the most fundamental concepts in system design, and almost every interview will touch on it. Understand this well, and you'll have a strong foundation for more advanced topics like horizontal scaling, microservices, and distributed systems.

    👨‍💻
    Sahil Sudan

    Software Engineer at Spense. I write about system design, web development, and fintech — explained simply for students and developers.