Load Balancer

Anshul Surpaithankar
7 min readJun 9, 2021

LOAD BALANCER

Late 20th and early 21st century saw the rapid rise of internet as the most preferred medium of communication across the world. The developing world also caught up to the technologically advanced developed world, with countries like India increasing the penetration of internet after the advent cheap internet plans specifically suited to mobile phone usage. It is estimated that there are an estimated 4.6 billion internet users across the world, nearly 60% of the world [1]. This has opened up avenues for social media, news portals and other websites to expand their reach.

Earlier companies needed to store all their data and software on their own hard drives and servers, and hence needed huge cost to setup their infrastructure and manage it. With growing number of internet users, the traffic which these companies handled increased exponentially. It became difficult for them upgrade their infrastructure each time to cater to the growing needs of servers.

This changed with the popularization of cloud computing. Cloud computing involved delivering different services like data storage, servers, databases, etc through the internet. In cloud computing, the infrastructure is completely managed by third-party vendors. Examples of cloud services are Google’s GCP, Amazon’s AWS, Microsoft’s Azure. This also helped smaller companies, individuals to host their mobile applications, websites through these services providers without going through the hassle of managing the servers, data storage.

With heavy usage of social media applications, websites among users, such applications and sites need to serve millions of simultaneous requests from the end-users and have to return the correct text and images or the related data asked for, responsively, and reliably. This is also accompanied by constant shifts in pattern of traffic depending on the geographical location, time of the year, with some sites handing more visitors during festive time than other times of the year. For effectively managing such surges in customer traffic, it became essential to distribute the load among servers to ensure prevention of overloading of servers.

Hence, the concept of load balancing came into prominence in the domain of cloud computing. Load balancing is the concept of distribution of workloads across multiple servers. A load balancer acts as a traffic controller and directs incoming requests to available servers through specific algorithms. If any server shuts down, the load balancer automatically distributes its workload to other servers. Ensuring that no single server is overloaded, load balancing helps improve responsiveness and availability of websites for the user. The concept of balancing the load with a dedicated Load Balancer unit is a much more economical and effective way of ensuring the peak performance of the website or application and offering the end-user a great experience. Through this blog we will explain the basics of working of a load balancer, compare between the load balancers provided by different vendors and find out the advantages and disadvantages of the load balancer.

How does it work?

In cloud computing having several resources does not guarantee its optimized use. The management of those resources can become the deciding factor for users to come back again to use the services. High availability and consistency are the main features of a scalable and efficient system that can improve customer satisfaction to a great extent. Load balancers help to distribute incoming client requests to computing resources such as application servers and databases. It routes the requests to a pool of computing resources allocated in the system and returns the response to the appropriate client. Scaling horizontally using shared resources is more cost-efficient and provides high availability than scaling up vertically which is expensive in nature. Load balancing can be done using hardware or software. Hardware load balancing is expensive compare to software. Load balancing can be done at the transport layer as well as the application layer. Load balancers can also help with horizontal scaling, improving the performance and availability of the system.

Typically, a load balancer sits between the client and the server accepting incoming network and application traffic and distributing the traffic across multiple backend servers using various algorithms. By balancing application requests across multiple servers, a load balancer reduces individual server load and prevents any one application server from becoming a single point of failure, thus improving overall application availability and responsiveness.

The load balancer sits between the client and the pool of servers accepting incoming requests and forwarding them to different servers based on the algorithm it is using. It can distribute the load across the servers avoiding the burden to a single server. It can also perform health check-ups to ensure the reliability of servers, server with a problem is removed from the pool. When a user wants to access a particular website with a URL it gets converted to an IP address using DNS, almost every scalable system has more than one server. But the companies do not provide IP for every single server instead, they provide IP for the load balancer, after all it is also a server. After the request reaches the LB, it then decides where to forward the given request.

Load balancer works on algorithms like

Ø Least connection method

Ø Least response time method

Ø Least bandwidth method

Ø Round Robin method

Ø IP hash method

The load balancer can become a single point of failure, hence to overcome this issue, systems generally have more than one balancing server.

Distribution of requests can be done at the following levels:

➢ Network and transport layer with parameters like IP address, UDP, and TCP ports.

➢ Application layer using HTTP header

➢ Global server level which considers the geographic location of the requests to serve efficiently.

Comparison of different load balancer services

Google Cloud Platform

The Google Cloud Load Balancer (GCLB) works on server-side load balancing in order to distribute incoming traffic to multiple VM instances, allowing users to direct applications across any region and scale compute with very little configuration. 0–1 million requests per second can be loaded with no pre-warming.

The three deployment types of load balancing services in Google are:

Ø Global Load Balancing — It supports HTTP(S) traffic for modern web-based applications. Traffic is distributed to the region that is closest to the calling user, provided the region has available capacity.

Ø Network Load Balancing- It directs traffic across virtual machine (VM) instances in the same region in a VPC network. Any TCP and UDP traffic can be load balanced on the basis of source, destination port, and protocol so that the traffic from the same connection reaches the same server.

Ø Internal Load Balancing- It is a regional load balancer that distributes the internal traffic across a set of back-end instances without requiring a public IP address.

Amazon Web Services

AWS’s Elastic Load Balancing (ELB) is used to distribute traffic across multiple EC2 instances. The service is changeable and fully managed i.e., it can automatically scale accordingly to meet demand.

The three types of load balancers available in AWS are Classic, Application and Network load balancer

Ø Classic Load Balancer (CLB) — It operates on both the request and connection levels for Layer 4 (TCP/IP) and Layer 7 (HTTP) routing. It is best for EC2 Classic instances.

Ø Application Load Balancer (ALB) — It works at the request level only. It is designed to support the workloads of modern applications such as containerized applications, HTTP/2 traffic, and web sockets.

Ø Network Load Balancer (NLB) — It operates at the fourth layer of the (OSI) Open Systems Interconnection model. It is capable to handle millions of requests per second.

AWS also provides third-party load balancing tools like Kemp LoadMaster and Barracuda Load Balancer in its Marketplace for more control. There is DNS based load balancing also which is offered through Route 53 which provides various routing and load balancing services. Route 53 is also useful in medical checks to send notifications through Cloud Watch.

Microsoft Azure

The three types of load balancers in Azure: Azure Load Balancer, Internal Load Balancer (ILB), and Traffic Manager.

Ø Microsoft’s Azure Load Balancer — It offers a higher-level scale with layer 4 load balancing across multiple VMs (virtual machines).

Ø Internal Load Balancer (ILB) — It has an internal-facing Virtual IP. Meaning, users can apply an internal load balancing for virtual machines (VM) that are connected only to an internal Azure cloud service or a virtual network.

Ø Traffic Manager — It is an internet-facing solution that balances the traffic loads at various endpoints using a policy engine as well as a set of DNS queries. It can route traffic to any region’s service and even to non-Azure endpoints.

Advantages & Disadvantages

Advantages

Ø Efficient Load Balancing enables High Performing Applications to deliver faster and better results at potentially lower cost.

Ø Load Balancing ensures distribution of increased traffic among various servers or network devices. Sites like E-commerce where frequency of users is high, load balancing plays a valuable role in managing any sudden traffic load.

Ø Load Balancing algorithms like dynamic algorithms are efficient in handling any sudden traffic spike without any effect in response time.

Ø Load Balancing also provides flexibility in case of failure of a working node. In such cases, the burden can be shifted to other active node.

Disadvantages

Ø Algorithms used for Load Balancing are complex to understand.

Ø Static load balancing algorithm fails in case of failure of system resource.

Ø Dynamic load balancing algorithm does not offer real support of server affinity.

Conclusion

As discussed earlier that possessing different resources does not imply an efficient cloud platform. Management and smart usage of these resources is essential which is carried out by Load Balancing. Many algorithms are developed to enhance Load balancing used by successful platforms like GCP’s Google Cloud Balancer, AWS’s Elastic Load Balancer, etc. Cloud Computing is a vast concept and Load Balancing plays an important role in making the concept more efficient and delivering better performance in lesser response time. Hence, we have discussed Load Balancing, its working methodology, implementation and applications in this blog.

References

1. https://www.statista.com/statistics/617136/digital-population-worldwide/#:~:text=How%20many%20people%20use%20the,the%20internet%20via%20mobile%20devices

2. https://www.educative.io/courses/grokking-the-system-design-interview/3jEwl04BL7Q

--

--