5 ๐๐จ๐๐ ๐๐๐ฅ๐๐ง๐๐ข๐ง๐ ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ๐ฌ ๐๐จ๐ฎ ๐๐ฎ๐ฌ๐ญ ๐๐ง๐จ๐ฐ
When building systems that lots of people useโโโlike websites, apps, or APIsโโโload balancing becomes super important. Itโs a common topicโฆ
5 ๐๐จ๐๐ ๐๐๐ฅ๐๐ง๐๐ข๐ง๐ ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ๐ฌ ๐๐จ๐ฎ ๐๐ฎ๐ฌ๐ญ ๐๐ง๐จ๐ฐ

5 Load Balancing Algo
When building systems that lots of people use โ like websites, apps, or APIs โ load balancing becomes super important. Itโs a common topic in interviews and a must-have in real-world projects that need to scale smoothly.
Before we jump into the different types of load balancing algorithms, letโs first understand what load balancing actually means.
โ๏ธ What Is Load Balancing?
Imagine youโve built a popular food delivery app. One evening, thousands of users open the app at the same time to place orders. If all those requests go to a single server, itโll get overwhelmed โ just like one chef trying to cook every meal alone.
A load balancer acts like a smart kitchen manager. It spreads the incoming orders (requests) across multiple chefs (servers), making sure no one is overloaded and every customer gets their food quickly.
Now that youโve got the idea, letโs explore the Top 5 Load Balancing Algorithms You Should Know โ with simple explanations and examples to help you understand how they work in practice.
1. Round Robin (The โTake Turnsโ Method)
Round Robin is one of the easiest ways to balance traffic between servers. Think of it like taking turns in a game โ each server gets a request one by one, in a loop.
๐ ๏ธ How It Works (Step-by-Step)
- The load balancer keeps a list of all available servers.
- When a new request comes in, it sends it to the next server in the list.
- Once it reaches the last server, it starts again from the first โ just like a circle.
โ When to Use Round Robin
ยท When all servers have similar capacity and performance.
- Tasks are short and roughly equal in size.
- Great for static websites or simple services where no request is heavier than the others.
๐ฝ๏ธ Real-Life Analogy
Imagine youโre serving food to a line of guests. You have 3 chefs: Chef S1, S2, and S3. You hand out orders like this:
- Order 1 โ Chef S1
- Order 2 โ Chef S2
- Order 3 โ Chef S3
- Order 4 โ Chef S1
- Order 5 โ Chef S2
- Order 6 โ Chef S3
And so on. Everyone gets a fair share, and no one is left behind.
2. Least Connections (Pick the Least Busy Server)
Least Connections is a smarter way to balance traffic. Instead of just taking turns like Round Robin, it checks which server is the least busy right now โ and sends the next request there.
๐ ๏ธ How it works?
- The load balancer keeps track of how many requests each server is currently handling.
- When a new request comes in, it sends it to the server with the fewest active connections.
- This helps avoid overloading servers that are already working hard.
โ When to Use Least Connections
- Requests vary in how long they take (like database queries or API calls).
- Some tasks might โstick aroundโ longer than others.
- Great for dynamic apps where traffic isnโt evenly spread.
๐ฝ๏ธ Real-Life Analogy
Imagine youโre at a bank with 3 counters:
- Counter A has 2 customers
- Counter B has 5 customers
- Counter C has just 1 customer
Youโd naturally go to Counter C, right? Thatโs exactly what Least Connections does โ it finds the shortest line
3. Weighted Round Robin (Let the Stronger Servers Do More)
Weighted Round Robin is like Round Robin โ but smarter. Instead of giving each server an equal number of requests, it gives more work to the stronger servers that can handle it.
๐ ๏ธ How It Works (Step-by-Step)
- Each server is assigned a weight โ a number that shows how powerful it is.
- Servers with higher weights get more requests.
- The load balancer rotates through the servers, but gives extra turns to the ones with higher capacity.
โ When to Use Weighted Round Robin
- Your servers have different CPU or memory sizes.
- Youโre running in a cloud setup with mixed instance types (some big, some small).
- You want to use all your resources efficiently without overloading weaker servers.
๐ฝ๏ธ Real-Life Analogy
Imagine youโre handing out deliveries to drivers:
- Driver S1 has a big van (weight 3)
- Driver S2 has a small scooter (weight 1)
For every 4 deliveries:
- S1 gets 3
- S2 gets 1
This way, the stronger driver does more work, and the smaller one isnโt overwhelmed.
4. IP Hash (Stick with the Same Server)
IP Hash is a load balancing method that makes sure each user keeps talking to the same server every time โ based on their IP address.
๐ ๏ธ How It Works (Step-by-Step)
- The load balancer takes the userโs IP address and runs it through a hash function (a kind of formula).
- That hash result decides which server the user gets connected to.
- As long as the userโs IP doesnโt change, theyโll always be routed to the same server.
โ When to Use IP Hash
- You need session persistence โ meaning the same user should always go to the same server.
- Perfect for apps like:
- ๐ Shopping carts (so items donโt disappear)
- ๐ฌ Chat apps (so conversations stay consistent)
๐ฝ๏ธ Real-Life Analogy
Imagine youโre assigning lockers at a gym based on someoneโs phone number:
- Person with number 192.168.1.5 always gets Locker A
- Person with number 192.168.1.6 always gets Locker B
Even if they come back tomorrow, theyโll get the same locker โ just like IP Hash keeps users tied to the same server.
5. Random (Just Roll the Dice)
Random is the most straightforward load balancing method. It doesnโt try to be smart โ it just picks a server at random for each request.
๐ ๏ธ How It Works (Step-by-Step)
- The load balancer doesnโt check how busy each server is.
- It simply chooses one at random and sends the request there.
- No tracking, no patterns โ just pure chance.
โ When to Use Random
- All servers are similar in power and speed.
- Youโre working in a test environment or handling lightweight tasks.
- Perfect when requests are quick and short-lived, and you donโt need fancy logic.
๐ฝ๏ธ Real-Life Analogy
Imagine youโre tossing a coin to decide which delivery driver gets the next order. You donโt care whoโs busier or faster โ you just let luck decide:
- Request โ Driver S2
- Request โ Driver S3
- Request โ Driver S1
- Request โ Driver S1
- Request โ Driver S3
Totally random, but it works when everyoneโs equally capable.
๐ Want to dive deeper? Iโm planning follow-up posts on 10 key Load Balancing algorithms with real-life examples & use cases. Stay tuned!
โจ Enjoyed this article? ๐ Support my work by
Your small gesture keeps me motivated to write more! ๐
๋ฉํ๋ฐ์ดํฐ
- post_id
- 3f937e2a73c8
- slug
- load-balancing-algo-3f937e2a73c8
- url
- https://medium.com/@md.zakirhossain/load-balancing-algo-3f937e2a73c8
- canonical_url
- https://medium.com/@md.zakirhossain/load-balancing-algo-3f937e2a73c8
- author_url
- https://medium.com/@md.zakirhossain
- status
- ok
- fetched_at
- 2026-06-25 07:00:49