0
0
HLDsystem_design~3 mins

Why Load balancing algorithms (round robin, least connections) in HLD? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your website could never slow down, no matter how many visitors arrive?

The Scenario

Imagine you run a busy restaurant with only one waiter taking orders and serving all tables. As more guests arrive, the waiter gets overwhelmed, orders get mixed up, and some tables wait too long while others get served quickly.

The Problem

Handling all requests manually means slow service and mistakes. The waiter can't remember who ordered what or who is waiting longest. Guests get frustrated, and the restaurant loses customers because the workload isn't shared fairly.

The Solution

Load balancing algorithms like round robin and least connections act like smart hosts who assign new guests to waiters evenly or based on who is least busy. This way, no waiter is overloaded, and guests get served faster and more fairly.

Before vs After
Before
sendRequestTo(server1)
sendRequestTo(server1)
sendRequestTo(server1)
After
sendRequestTo(roundRobin.next())
sendRequestTo(roundRobin.next())
sendRequestTo(roundRobin.next())
What It Enables

It enables smooth, fair, and efficient handling of many requests by spreading the load smartly across servers.

Real Life Example

When you visit a popular website, load balancers use these algorithms to send your request to the best server, so the site loads quickly even when millions are browsing.

Key Takeaways

Manual handling of requests causes delays and errors.

Load balancing algorithms distribute work evenly or by current load.

This improves speed, reliability, and user experience.