A High-Level Overview of Load Balancing Algorithms

Which one is right for your deploy needs?

Aastikta Sharma
Oct 26 · 4 min read
six small rocks balanced on top of each other in front of a waterfall
six small rocks balanced on top of each other in front of a waterfall
Photo by Martin Sanchez on Unsplash

Introduction

  • Routes data efficiently
  • Prevents server overloading
  • Performs health checks for the servers
  • Provisions new server instances in the face of large traffic

Types of Load Balancing Algorithms

diagram of the layers in the OSI model with arrows indicating where the application load and network load balancers are used
diagram of the layers in the OSI model with arrows indicating where the application load and network load balancers are used

The different types of LB algorithms are effective in distributing the network traffic based on how the distribution of traffic looks, i.e., whether it’s network layer traffic or application layer traffic.

  • The network layer traffic is routed by LB based on TCP port, IP addresses, etc.
  • The application layer traffic is routed based on various additional attributes like HTTP header, SSL, and it even provides content switching capabilities to LBs.

Network Layer Algorithms

1. Round-robin algorithm

  • Weighted round-robin: If the servers are not of identical capacity, then this algorithm can be used to distribute load. Some weights or efficiency parameters can be assigned to all the servers in a pool and based on that, in a similar cyclic fashion, load is distributed.
  • Dynamic round-robin: The weights that are assigned to a server to identify its capacity can also be calculated on runtime. Dynamic round-robin helps in sending the requests to a server based on runtime weight.

2. Least-connections algorithm

3. Weighted least-connections algorithm

4. Least-response-time algorithm

5. Hashing algorithm

  • Source/destination IP hash: The source and destination IP addresses are hashed together to determine the server that will serve the request. In case of a dropped connection, the same request can be redirected to the same server upon retry.
  • URL hash: The request URL is used for performing hashing, and this method helps in reducing duplication of server caches by avoiding storing the same request object in many caches.

6. Miscellaneous algorithms

  • Least-bandwidth algorithm: The server with the least consumption of bandwidth in the last 14 minutes is selected by the load balancer.
  • Least-packets algorithm: Similar to above, the server that is transmitting the least number of packets is chosen by the load balancer to redirect traffic.
  • Custom-load algorithm: The load balancer selects the server based on the current load on it, which can be determined by memory, processing unit usage, response time, number of requests, etc.

Application Layer Algorithms

One of the most significant algorithms used at this layer is the least-pending-request algorithm. This algorithm directs the traffic of pending HTTP(s) requests to the most available server. This algorithm is helpful in adjusting the sudden spike in requests by monitoring the server load.

Conclusion

Better Programming

Advice for programmers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store