Load Balancer: How it Improves Web Performance

Whenever we want to connect to the Internet, we need websites to be accessible as quickly as possible, to have the best user experience. However, we must remember that these websites are hosted on web servers and these, in turn, have a capacity limit. A website with high demand could not really survive without a load balancer . This tool allows the website we administer to be always available, and to be able to serve all requests at the highest possible speed. This tutorial will explain how a load balancer, or also known as Load Balancer , can improve the performance of your website.

Websites that offer services such as online shopping, online press, or multimedia services have a high demand for traffic on an almost continuous basis, especially in the evening, which is when there is the most Internet traffic because everyone is in their houses resting from a hard day at work. The web servers are mainly responsible for the fact that when we visit a certain website, the page load is very fast to provide the best possible user experience.

Each of the online businesses ( e-commerce ) must keep in mind that it is mandatory to have high performance and availability web servers. Just a few brief events of slow or no access to shopping sites, and even problems making payments, can influence the customer’s decision to re-shop on such sites.

load balancer

How can a Load Balancer help?

If you are responsible for the infrastructure that gives life to high-demand websites such as e-commerce, and you want to ensure that web servers maintain high levels of service, you should take into account mounting an infrastructure with load balancing, or also known as Load Balancing .

What are they for? These ensure that web traffic is not concentrated on a single server, which eventually ends up becoming saturated due to the thousands of requests per second that it receives from different clients. In turn, this saturation leads to extreme slowness of the websites or simply that it is not available and returns an error. In fact, the Load Balancer “role” can be fulfilled by a web server itself. Instead of constantly investing in the acquisition of a single server of increasing capacity, you could choose two or more servers with identical features in order to balance traffic on each one.

To apply this balancing process, it is customary to opt for DNS Round-Robin functionality to distribute client requests equally to web servers. The result is consistent server availability and performance. The disadvantage of this process is that it is not applicable in a scenario where the servers have different features and capabilities . Round-Robin treats all available servers equally and does not verify whether they are operating or not available.

As a result, the different suppliers applied improvements. They did this by creating tools that ensure that servers are fault tolerant: load balancers . This, by redirecting traffic and clients from one failed server to another available. Thus, users will perceive very few inconveniences and zero failures. These tools can be used both in multiple website environments, as well as those with only one.

Operating scheme

As we have mentioned, a load balancer is a tool, which directs a client to the web server that is most available among those with the same content. This process is completely transparent for those who access a certain site, so that at first glance we cannot detect this. We can use this scheme to better understand how it works:

  • There are two web servers that are responsible for feeding a single website. The IP addresses are:
    • 192.168.0.4 for server web1.example.com
    • 192.168.0.5 for web2 server example.com
  • A load balancer is implemented with the virtual hostname www.ejemplo.com and its virtual IP 192.168.0.10. That virtual host, with name and virtual IPs, is what will serve the DNS server to resolve access to the “example” website
  • A person wants to access www.example.com , so what happens is that they are actually making a request to access the load balancer of the servers that originally host the website.
  • That load balancer now checks which web server is available for user request. Once that is done, the chosen server receives the request.
  • Once you have successfully processed it, the server itself responds to the request by providing access to the website www.example.com . This could change according to how it has been implemented.

Types of load balancers

Fundamentally they are classified into three types:

  • Hardware type: It consists of a dedicated server with a specific operating system, and software to do the load balancing process. This server integrates web servers using Plug and Play solutions, which means that as soon as they connect, they work with little or no pre-setting.
  • Switch type: A load balancer of this type needs a Layer 2 or Layer 3 switch for the integration of the balancing process. No intermediary device is required between the switch and the web server.
  • Software-based: In this case it is not necessary to modify any network connectivity feature. You can install the software for the purpose on the web servers themselves. However, you can opt for a dedicated server to fulfill the role of load balancer.

In either case, the fundamental purpose is met: monitoring the capacity of web servers, selecting the appropriate server for each client’s requests, and redirecting traffic between the client and the server.

How traffic is redirected

As we already know one of the main purposes of a load balancer is to redirect traffic from the client to the appropriate server. Next, we will share how they do it:

MAT

These acronyms correspond to M edia Access Control A ddress T ranslation. This method requires each web server to use the load balancer IP address as a loopback interface address, in addition to its own IP. When the load balancer receives the request from the client, it begins selecting the appropriate web server. It then changes the destination MAC address in the data packet that makes up the client’s request to that of the chosen web server. Later, that request travels to the server, which contains the client’s IP address as data. In this way, it guarantees a direct response to it.

One point to consider is that whenever the “chosen” web server responds to the client’s request, it masks its original IP with that corresponding to its load balancer. As if the client made a request to it originally.

NAT

The method is to change the destination IP address of the client request. Originally, the latter is directed to the IP of the load balancer. However, the popular “nateo” process changes this IP and assigns the one that corresponds to the “chosen” server. This process is carried out by the load balancer itself through its assigned IP address. Also, in the midst of this process, the source IP address is that of the load balancer instead of the client’s IP address. Once the load balancer redirects the response to the client, it changes the destination IP address to the one corresponding to the client. Consequently, the IP address listed as the source is that of the load balancer.

What is achieved is to hide the original IP of the web server, that it is not visible to clients. So web servers can use any IP, even if it is private. These servers do not need to connect directly to the load balancer in the sense of belonging to the same local network segment. As long as web servers and load balancers can communicate using static routes or network routing protocols, there is no need.

TCP gateway

In this method, load balancers have to redirect traffic at the TCP layer and higher. Both this and the client making the connection request establish a TCP connection . So the load balancer receives the request data already before searching for the most appropriate server. The load balancer then establishes a TCP connection to the already designated server to transmit the client request. This load balancer also passes the response from the server to the client through the TCP connection. Thus, we see that the TCP protocol acts as an intermediate between the potential destination servers, the load balancer and the client.

As we see, the function of a load balancer has become increasingly essential. Mainly, because websites are receiving more and more customer requests, that is, more users who want to access the different pages. Not only is e-commerce one of the sectors that this type of tool should adopt, but also any other that has high day-to-day user traffic.