Chat / Contact

Latest News from 100TB

What Is Load Balancing And How Does It Work?

Load balancers form a vital part of multi-server clusters and high availability (HA) solutions. But what are they and how do they work? Find out here.

What is Load Balancing?

On a basic level a load balancer acts a lot like a router, in that it directs inbound traffic to different servers as required. Unlike the router, that makes the decision based on the target IP address on the traffic, the load balancer decides which server should handle the request based on how hard the various servers are working.

The load balancer itself can take the form of a dedicated network appliance which performs both the load balancing act and possibly some switching as well, or alternately could be built from a high performance dedicated server running load balancing software such as HAproxy or Piranha.

So let’s, have a look through some of the use cases for when you might need a load balancer:

High Availability

A highly available solution is one where the design is such that the service should never appear to be offline to the end user. In this design, every server used should have a fail-over of some nature, so that should any server die there is another ready to take its place. A load balancer would be used in this situation to direct the traffic to the various servers and ensure that the user’s requests aren’t sent to any offline servers.

Server Clusters

Server clusters are when multiple servers are all performing the same tasks. The purpose for these are situations such as when a website becomes too popular for one server to handle and the load needs to be spread over multiple servers. For situations like this the load balancer’s purpose is to both provide a single IP to which the users will be connecting, and also to ensure that the incoming requests are split between the various servers.

How Does Load Balancing Work? A Simple Overview

When using a load balancer, generally the load balancer will sit between the servers that deal with user requests and the outside internet (a bit like how you would place a network firewall). Taking the example of a load balancer for a website, the site’s domain would be pointed to the external IP address of the load balancer. This means that when a user clicked a link on the website they’d be sent to the load balancer. The load balancer would then forward this incoming traffic on to one of the servers that sits behind it and deals with serving web pages.

There are a number of methods that the load balancer can use to forward the traffic on to the servers.

The most simple is to use the servers in a round-robin fashion. This would work as a way of holding a list of the server IPs, it would issue each incoming connection an IP from the list in order until it reaches the end and starts again from the beginning. While this works for spreading the load, it doesn’t spread things evenly amongst the servers.

More advanced solutions will monitor the load on the various servers behind it.

This will ensure that the incoming connection is always directed to the server with the lowest load. They can also check to see if any of the servers are down, how fast they are responding to requests and how many individual connections they are currently handling in order to make decisions. Once an initial connection has been made, the load balancer can then either ensure it sends repeated requests from the same source to the same server, or it may always select a “random” server based on its algorithms for each connection.

Often the load balancer is generally used with a second.

This pairing will ensure that if the initial load balancer has problems that the secondary one is able to step in and take over the workload. This is very important when working with a highly available solution as otherwise the load balancer can become a single point of failure.There we have it, a simple overview of a load balancer and how it works. If you are thinking you might need this for your solution then you can either use a pre-built solution such as is offered from the likes of Barracuda Networks or Array Networks, or alternately build your own solution on dedicated server hardware.