Load Balancing in System Design Explained with Real-World Examples

Load Balancing is one of the most important concepts in System Design interviews and real-world applications.

If you’ve ever wondered:

  • What is a Load Balancer?
  • Why do we need Load Balancing?
  • What problem does it solve?
  • What happens without it?

This guide will explain everything in simple language.


Imagine a Restaurant

Suppose there is only one cashier at a restaurant.

Customer 1 → Cashier
Customer 2 → Waiting
Customer 3 → Waiting
Customer 4 → Waiting

As more customers arrive:

  • Queue becomes longer
  • Waiting time increases
  • Cashier becomes overloaded

Now imagine the restaurant adds 5 cashiers.

Customer 1 → Cashier 1
Customer 2 → Cashier 2
Customer 3 → Cashier 3
Customer 4 → Cashier 4
Customer 5 → Cashier 5

Everyone gets served faster.

This is exactly what Load Balancing does.


What is Load Balancing?

Load Balancing is:

The process of distributing incoming traffic across multiple servers instead of sending everything to a single server.

Instead of:

Users
Server 1

We do:

   Users  
     ↓
Load Balancer
     ↓ 
┌─────────┐ 
↓    ↓    ↓
S1   S2   S3

The Load Balancer decides which server should handle each request.


Why Do We Need Load Balancing?

Imagine your website gets:

10 users per day

One server may be enough.

But suddenly:

100,000 users visit

One server might:

  • Become slow
  • Crash
  • Stop responding

Load balancing prevents this problem.


What Happens Without Load Balancing?

Without load balancing:

Users
Server 1

Problems:

❌ Server Overload

Too many requests hit one server.


❌ Slow Response Time

Users wait longer.


❌ Single Point of Failure

If server crashes:

Server Down = Application Down

Entire application becomes unavailable.


❌ Poor Scalability

Cannot handle traffic growth efficiently.


Benefits of Load Balancing

1. Better Performance

Traffic is distributed evenly.

1000 Requests
333 → Server 1
333 → Server 2
334 → Server 3

No single server becomes overloaded.


2. High Availability

If one server fails:

Server 1 ❌
Load Balancer
Server 2
Server 3

Users are automatically redirected.

Application remains available.


3. Scalability

Need more capacity?

Simply add more servers.

S1
S2
S3
S4
S5

Load balancer starts using them automatically.


4. Better User Experience

Users get:

  • Faster pages
  • Better reliability
  • Less downtime

Real-World Example

Imagine:

Amazon Sale

Millions of users visit simultaneously.

Without load balancing:

One Server
Crash

With load balancing:

  Users  
    ↓
Load Balancer
    ↓
100+ Servers

Traffic is distributed safely.


How Does a Load Balancer Work?

Step-by-step:

Step 1

User opens:

www.example.com

Step 2

Request reaches:

Load Balancer

Step 3

Load Balancer checks:

  • Which server is free?
  • Which server is healthy?
  • Which server has fewer requests?

Step 4

Request is forwarded.

  User 
   ↓
Load Balancer 
   ↓
Server 2

Step 5

Server responds.

Server 2
Load Balancer
User

Load Balancing Algorithms

A Load Balancer needs rules to decide where traffic goes.


1. Round Robin

Most common.

Requests are distributed one by one.

Request 1 → S1
Request 2 → S2
Request 3 → S3
Request 4 → S1
Request 5 → S2

2. Least Connections

Send traffic to the server with fewer active users.

Example:

S1 → 200 users
S2 → 50 users
S3 → 100 users

Next request goes to:

S2

because it has fewer connections.


3. Weighted Round Robin

Powerful servers get more traffic.

Example:

S1 = Weight 5
S2 = Weight 2

S1 receives more requests.


4. IP Hash

Same user always goes to the same server.

Useful for:

  • Shopping carts
  • User sessions

Types of Load Balancers


Hardware Load Balancer

Physical device.

Examples:

  • F5 BIG-IP

Usually expensive.


Software Load Balancer

Runs as software.

Examples:

  • NGINX
  • HAProxy
  • Traefik

Most companies use these today.


Cloud Load Balancer

Managed by cloud providers.

Examples:

  • AWS Elastic Load Balancer (ELB)
  • Azure Load Balancer
  • Google Cloud Load Balancer

Very popular.


Where Is Load Balancing Used?

Almost everywhere.

Websites

Google
Facebook
Amazon
Netflix

Banking Applications

To handle millions of transactions.


E-commerce Platforms

For handling traffic spikes during sales.


APIs

To distribute API requests.


Load Balancing in Kubernetes

In Kubernetes:

Ingress
Service
Pods

Load balancing happens between Pods.

Example:

Pod 1
Pod 2
Pod 3

Traffic gets distributed among all pods.


Real System Design Architecture

                       Users 
                        ↓          
                  Load Balancer                   
                        ↓     
              ┌────────┬────────┬────────┐ 
              ↓        ↓        ↓ 
          Server1   Server2   Server3     
              ↓        ↓        ↓          
                    Database

This architecture is commonly used in production systems.


Interview Definition

If asked in an interview:

Load Balancing is a technique used to distribute incoming requests across multiple servers to improve performance, scalability, availability, and fault tolerance.


🏁 Final Summary

Load Balancing is like having multiple cashiers in a supermarket instead of one.

Without Load Balancing:

❌ Slow system
❌ Server crashes
❌ Downtime
❌ Poor user experience

With Load Balancing:

✅ Faster response times
✅ Better availability
✅ Easy scalability
✅ Improved reliability


💡 Simple One-Line Definition

A Load Balancer acts like a traffic police officer that intelligently distributes user requests across multiple servers so that no single server becomes overloaded.

What is an Ingress File in Kubernetes? Complete Beginner Guide

When beginners open a project repository, they often see files like:

ingress.yaml

or:

my-app-ingress.yml

and immediately get confused:

🤔 What is ingress?
🤔 Why do we need it?
🤔 What does this file do?
🤔 Is it mandatory?
🤔 What happens if we don’t use it?

If you are completely new to:

  • Kubernetes
  • DevOps
  • deployments
  • infrastructure

don’t worry.

This guide explains everything in a very simple way with real-world examples.


First Understand the Problem

Imagine you built a React or Node.js application.

Now you deployed it inside Kubernetes.

Question:

🤔 How will users access your application from the internet?

Because Kubernetes containers are running internally.

Users outside cannot directly access them.

This is where:

Ingress

comes into the picture.


What is Ingress?

Ingress is:

A way to expose your application to the outside world.

In simple words:

👉 It helps internet users access your application.


Real-World Analogy

Imagine:

  • Your application = a house
  • Kubernetes cluster = a big apartment building
  • Users = visitors

Without ingress:

❌ Visitors don’t know:

  • where to go
  • which room belongs to which application

Ingress acts like:

security guard + receptionist

It:

  • receives requests
  • checks the URL
  • sends users to correct application

What is an Ingress File?

An ingress file is usually:

ingress.yaml

It contains rules that tell Kubernetes:

  • which domain should go where
  • which route should open which service
  • how incoming traffic should be handled

Example Ingress File

apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: my-app-ingressspec: rules: - host: myapp.com http: paths: - path: / pathType: Prefix backend: service: name: my-app-service port: number: 80

What This File Means

This says:

If user visits myapp.com,send request to my-app-service

What Problem Does Ingress Solve?

Without ingress:

every application may need:

  • separate public IP
  • separate load balancer
  • direct exposure

This becomes:

  • expensive
  • difficult to manage
  • hard to scale

Ingress Solves This

Ingress provides:

  • centralized routing
  • domain-based routing
  • path-based routing
  • SSL handling
  • traffic management

Real Example

Suppose you have:

ApplicationURL
React Appmyapp.com
Admin Panelmyapp.com/admin
API Servermyapp.com/api

Ingress can route all these properly.


Without Ingress

You may need:

3 separate load balancers3 public IPs

With Ingress

One ingress handles everything.


How Request Flows

Request Flow

User opens website ↓Ingress receives request ↓Checks rules ↓Forwards request to correct service ↓Application responds

Important Thing to Understand

Ingress does NOT directly connect to pods.

Flow is:

Ingress → Service → Pods

Beginner-Friendly Architecture

Internet User ↓Ingress ↓Kubernetes Service ↓Pods/Containers

What is a Service?

A service is another Kubernetes component that:

  • connects to pods
  • provides stable networking

Ingress talks to services.

Services talk to pods.


Why We Need Ingress


✅ 1. Domain Routing

Example:

myapp.comapi.myapp.comadmin.myapp.com

✅ 2. Path Routing

Example:

/api/admin/profile

✅ 3. SSL/HTTPS Support

Ingress can handle:

HTTPSTLSSSL certificates

✅ 4. Centralized Traffic Management

One place to manage all traffic.


✅ 5. Cost Reduction

Instead of many load balancers:
👉 one ingress can handle multiple apps.


What Happens If We Don’t Use Ingress?

Your app may still work.

BUT:

you may need:

  • NodePort
  • LoadBalancer service
  • direct exposure

Problems Without Ingress

❌ More Public IPs Needed

❌ More Expensive

Cloud load balancers cost money.

❌ Harder Traffic Management

❌ Difficult SSL Handling

❌ Difficult Multi-App Routing

Difference Between Service and Ingress

ServiceIngress
Internal communicationExternal access
Connects to podsRoutes internet traffic
Exposes app inside clusterExposes app outside cluster

What is Ingress Controller?

This is VERY important.

Ingress file alone does nothing.

You also need:

Ingress Controller

What Does It Do?

It actually:

  • reads ingress rules
  • handles traffic
  • applies routing

Popular Ingress Controllers

  • NGINX Ingress Controller
  • Traefik
  • HAProxy
  • AWS ALB Ingress Controller

Without Ingress Controller

Ingress file exists…

BUT:

❌ routing will NOT work.


Real Beginner Confusion

Many beginners think:

Creating ingress.yaml is enough

❌ Wrong.

You also need:

  • ingress controller installed

Example Real Repository Structure

project/ ├── src/ ├── deployment.yaml ├── service.yaml ├── ingress.yaml

Why YAML Files?

Kubernetes uses YAML files to define infrastructure.

These files describe:

  • deployments
  • services
  • ingress rules
  • volumes
  • configs

Important Kubernetes Files

FilePurpose
deployment.yamlCreates pods
service.yamlExposes pods internally
ingress.yamlExposes application externally

Simple Full Flow

Full Architecture

User ↓Ingress ↓Service ↓Pod ↓Application

Best Practices

✅ Use Ingress for Production Apps

✅ Use HTTPS

Always secure traffic.

✅ Organize Routes Clearly

✅ Use One Ingress for Multiple Apps

Saves cost.

Common Beginner Mistakes

❌ Forgetting Ingress Controller

Most common issue.


❌ Wrong Service Name

Ingress routes fail.


❌ Wrong Port Number

Traffic not forwarded properly.


❌ DNS Not Configured

Domain won’t work.


Final Summary

✔ Ingress exposes applications to internet users
✔ It routes traffic to correct services
✔ Helps manage domains and paths
✔ Reduces infrastructure complexity
✔ Requires an ingress controller to work
✔ Commonly defined using ingress.yaml file


💡 Found this helpful? Subscribe for beginner-friendly DevOps and Kubernetes guides explained in simple language. Happy Coding!