← Back to Portfolio

I confused myself thinking about Load Balancers

β€’3 min readβ€’Shakirul Hasan Khan
System DesignLoad BalancerDNSNetworkingArchitecture

I confused myself thinking about Load Balancers yesterday πŸ˜΅β€πŸ’«

Here's the question that came to my mind:

If a Load Balancer (LB) routes users to the nearest server for low latency... And I'm in Bangladesh requesting from an LB hosted in USA...

Doesn't my request look like this:

Me (BD) β†’ LB (USA) β†’ Server (BD) β†’ LB (USA) β†’ Me (BD)

That's more latency, not less! 🐌

So should we have LBs in every region? But then... how does a user know which LB to connect to? πŸ€”

Do we need a Load Balancer for Load Balancers? πŸ˜…

The Answer

The answer: Yes. And it already exists. It's called DNS (Domain Name System).

Here's what actually happens:

  1. You type example.com
  2. DNS sees your IP is from Bangladesh
  3. DNS returns the IP of the BD load balancer
  4. You connect directly to BD, no USA roundtrip!

Your friend in USA? DNS gives them the USA server IP.

Why do we need both?

But wait, then why do we even need Load Balancers? πŸ€”

Because DNS and LB solve different problems:

  • DNS = Which datacenter? (geographic, cached for hours)
  • LB = Which server in that datacenter? (real-time, health-aware)

DNS is like GPS saying "go to Dhaka Medical Hospital." LB is the reception desk saying β€œFloor 10, Room 5, Dr. Rahman is free."

GPS doesn't know which doctor is available. Reception doesn't help you find the hospital.

Confusion about Load Balancers diagram

You need both.

Conclusion

Sometimes the best way to learn system design is to confuse yourself with a silly question and then dig your way out. 😎


Read this article on Substack or LinkedIn