An Introduction to Load Balancing

So, if you have been working on web services in this half of the decade, you must have come across the term “load balancing”. So what is load balancing? Let’s find out!

What is load balancing?

Load balancing

How does load balancing work?

  1. Client-side
  2. Server-side

Client-side load balancing

The simplest example is a DNS based load-balancing. Most websites (including Medium) use multiple web servers to handle the traffic. Every time you visit a website, the browser asks the DNS servers to provide a list of IP addresses of servers hosting the website’s content. If the DNS responds with multiple servers, the browser chooses one and sends the request. For subsequent requests, the browser would choose another server from the list of servers returned by the DNS earlier.

Client-side load balancing is also used in microservices utilizing a service discovery framework like Consul or a service mesh like Istio.

Advantages

  1. Simple to implement

Disadvantages

  1. There will be an uneven load distribution

Server-side load balancing

Advantages

Disadvantages

Load balancing algorithms

Round-robin

Least Connection

Weighted

Adaptive

Sticky

This was a small intro about load balancing. The best way to learn is to spin-up a few servers and experiment. You can use ready-to-spin docker containers or virtual machines to deploy a copy of an app and a load-balancer and watch it in action.

If you liked this post, subscribe to my newsletter to never miss the next interesting round of tech stories.

Computer Whisperer. Open-source contributor. Find me at https://amitosh.in/