What is Load Balancing in AWS?

Learn via video courses
Topics Covered

Overview

To balance any type of workload in a particular field, we need a manager who manages it. Similarly, to manage the traffic on a website, we need a load balancer who manages the users' traffic and distributes it among multiple servers. Load Balancer is a server that distributes the network or traffic of any application across multiple servers.

What is Load Balancing?

Let's understand the concept of load balancing with an example. Suppose we have our application running on a server. What if our application went viral overnight? Is our single server capable of handling millions of requests? The answer is no, and it generally results in a server crash, and eventually, we will lose customers.

To resolve this, we need to deploy multiple servers. But how are we going to connect users to various servers? Let's take the example of Google. Does Google provide a list of IPs, saying if one IP is not working, then connect to the other? No, right? So to manage and redirect user traffic across multiple servers load balancer is used.

What is Load Balancing-1

Load Balancing is a method in which we can distribute network traffic across multiple resources with the help of a load balancer that supports an application. Load Balancing is also known as server pool. It plays a vital role in increasing the reliability and performance of a website.

What is Load Balancing-2

A load balancer is present to do the load balancing between the user and the server group. It acts as an invisible facilitator who checks that the servers in the server group are used equally.

How Does It Work?

Load Balancing works with the help of a load balancer, which acts as a traffic police and guides the client's request to a particular app server.

Let's understand the working of load balancing with the help of the diagram given below:

How Does It Work

Let's take an example of a website where many users use the applications simultaneously.

  • Requests generated by every user are sent to the load balancer using the internet.
  • The load balancer, either a hardware or software-based server, balances the traffic of all the users and is sent accordingly to the app servers.
  • It's the load balancer's job to route each request from the users to a single app server best suited to handle the request.
  • Load Balancing is just like a job of a manager who assigns projects to specific employees who are best suited to work on that project in a company.

History

Now we know what load balancing is, let's explore its history and origin.

  • The number of applications increased with the improvement of networking technologies and the internet.
  • The number of requests per application also increased rapidly, which became difficult to handle using individual servers.
  • Hence, the need arise for the developers to find something which can distribute traffic across multiple servers instead of a single server to improve performance. This led to the creation of load balancers.
  • In the 90s, load balancing started distributing traffic across a network using hardware appliances.
  • When the Application Delivery Controllers (ADCs) came into the picture, load balancing took more responsibilities to provide security when accessing the applications.

Load Balancing Algorithms

There are two main categories of Load Balancing algorithms. Let's discuss in brief about them.

Static Load Balancing Algorithms

  • Static Load Balancing Algorithms distribute network traffic across application servers without checking the server's state.
  • It is designed to distribute the traffic without checking the health and availability of the application server.
  • It will redirect an equal amount of traffic even if a server is poorly performing, which leads to a bad user experience.
  • Some of the common static load balancing algorithms are:
    • Client-Side Random load balancing method
    • Round Robin load balancing method
    • Weighted Round Robin load balancing method
    • IP Hash load balancing method

Common Static Load Balancing Algorithms

  • Round Robin Method: Client request is forwarded to the application servers sequentially using a rotating list. The rotating list contains the list of IP addresses of application servers.
  • Weighted Round Robin Method: Under this, each application server is assigned a particular weight based on its capacity and strength. Then, the client requests are directed to these servers based on the weight sequentially using the rotating list.
  • IP Hashing Method: The load balancer performs hash operations on the IP of the incoming packet. Based on this, hash value requests are redirected to application servers.

Dynamic Load Balancing Algorithms

  • Dynamic Load Balancing Algorithms first check the application servers' condition, health, and availability based on the application system state in which it distributes traffic.
  • If an application server performs poorly, it redistributes the traffic and redirects it to other healthy servers.
  • Some of the common dynamic load-balancing algorithms are:
    • Least connection load balancing method
    • Weighted least connection load balancing method
    • Resource-based load balancing method
    • Least bandwidth load balancing method

Common Dynamic Load Balancing Algorithms

  • Least Connection Method: A connection represents a communication channel between an application server and the client. When a client connects to the server, the connection becomes active. Therefore, further client requests are redirected to application servers based on the least active connections in an application server.
  • Weighted Least Connection Method: Weight is assigned to application servers based on their capacity to handle the number of active connections. Based on this weight, client requests get redirected.
  • Resource-Based Method: Load balancer figures out the load on the application servers and then distributes client requests to the one with the most resource available.

Types of Load Balancing

Let's know about the types of load balancing. Load Balancing is categorized into the following categories based on the elements checked by the load balancer to redirect the traffic.

Application Load Balancing

Application Load Balancing is the load balancing type for complex applications with several server farms. In such applications, the application load balancer looks out for the requested content from HTTP headers or SSL session IDs to redirect traffic.

For better understanding, let's understand it with an example. We will see different applications related to delivery. These applications have product catalogs, carts, and user checkout pages. The product application page is stored on one server, and the images and videos of the products are on another server. To fetch the images from the server, the product page needs to establish an open connection only sometimes, as the same data can be redirected to a server having multiple connections. Therefore, the data of the cart remains the same for a long time.

Network Load Balancing

Network Load Balancing is the type of load balancing in which the load balancer checks the IP address and network configuration to redirect the traffic. These load balancers assign a static IP address to their servers and balance the traffic across two or more Wide Area Networks.

Network Load Balancing uses the static and dynamic load balancing algorithms discussed earlier.

Global Server Load Balancing

As its name suggests, Global Server Load Balancing is the type of load balancing in which it balances servers across the globe in different geographical locations. In such load balancing, applications are managed by the local load balancers in each region.

Let's suppose a company whose application is accessed in a different part of the world, in different countries; then Global Server Load Balancing is used. It tries to redirect the traffic which is geographically closer to the users.

DNS Load Balancing

DNS Load Balancing is another load balancing type in which we configure the domain name to route the network requests and distribute them across servers. We can provide domain to any service accessible through the internet, like a website, a mail system, a print server, etc.

It maintains the availability of the applications and balances the network traffic across servers.

Types of Load Balancing Technology

Load Balancing is classified into two types of Load Balancing Technology. They use hardware load balancers and software load balancers.

Hardware Load Balancers

Hardware Load Balancer is a hardware appliance that helps manage gigabytes of traffic to hundreds of servers. It manages the request traffic securely. It is a hardware device, and we can store it in the data center and use it as multiple digital or virtual load balancers with the help of virtualization.

Software Load Balancers

Software Load Balancers perform all the load-balancing functions, but it is in software form. We can install these load balancers on any server. We can access the software load balancer as a third-party service that is fully managed.

Benefits and Limitations of Load Balancing

Benefits of Load Balancing

The following are the benefits provided by load balancing:

  • Load Balancing makes the application server more available, as it maintains or upgrades the application without downtime.
  • It makes the application more scaleable as it adds or removes the number of servers according to the number of cliclientsquests it receives.
  • Load Balancing adds redundancy to the system, which will help it to scale perfectly.
  • Load Balancing also provides us with application security. It deals with many attackers and automatically redirects the attacked traffic to the other backend server, which will try to minimize the impact of any attack on the application.
  • It also increases the application's performance by increasing the response time and reducing the network latency.

Limitations of Load Balancing

The following are the limitations of load balancing:

  • If the load balancer fails in an application, it may take down the entire cluster.
  • Load Balancing is difficult to set up for new network administrators.
  • Sometimes, it is difficult to diagnose the problems, as it uses the dynamic configuration of server groups.

Software Load Balancers vs Hardware Load Balancers

Let's discuss the differences between Software load balancing and Hardware load balancing:

FeaturesSoftware Load BalancingHardware Load Balancing
PricingThe price of Software Load Balancing is pocket-friendly as no hardware components need to be maintained.Hardware Load Balancing is very costly because we must buy the hardware components.
ScalingSoftware Load Balancing service is more scaleable and easier to scale as we can easily add new virtual servers.It is not easy to scale because if we need extra power in the future, it requires more hardware components, which is costly.
Disaster RecoveryIt has an easy recovery option and a better failover. The software backups can be easily maintained.It is not easy to recover when it fails due to some disaster as the hardware appliances are impacted.
MaintenanceIt requires low maintenance as it does not involve the use of any hardware devices.It requires good maintenance for the hardware equipment.
BenefitsThe benefits associated with hardware load balancers include flexibility and isolation. The multi-tenant architecture can be implemented and changed flexibly. In addition, the servers and appliances can be isolated from each other.Software load balancers can be configured based on technical requirements. They can run on hypervisors, containers, etc., without using many resources.

DNS Load Balancing vs Hardware Load Balancing

Let's discuss the differences between DNS load balancing and Hardware load balancing:

FeaturesDNS Load BalancingHardware Load Balancing
PricingThe price of DNS Load Balancing is friendly as it offers a subscription-based service.Hardware Load Balancing is very costly because we must buy the hardware components.
ScalingDNS Load Balancing service is more scaleable and easier to scale.It is not easy to scale because if we need extra power in the future, it requires more hardware components, which is costly.
Disaster RecoveryIt has an easy recovery option and a better failover.It is not easy to recover when it fails due to some disaster as the hardware appliances are impacted.
MaintenanceIt requires low maintenance as it offers mostly managed DNS.It requires good maintenance for the hardware equipment.

How can AWS Help in Load Balancing?

AWS provides us with a dedicated service for load balancing called Elastic Load Balancer. AWS fully manages it. We can easily scale our applications to distribute incoming traffics on multiple app servers. In other words, Elastic Load Balancer is a load balancer in AWS that provides an automated load balancing service.

Elastic load balancing supports four types of load balancers. They are:

  • Application Load Balancer - HTTP-based traffic requests are routed on this load balancer.
  • Network Load Balancer - The network load balancer is based on the IP address. Such load balancers are best for TCP and UDP-based traffic requests.
  • Gateway Load Balancer - Gateway load balancers are mainly for incorporating a third-party appliance like a network firewall into network traffic in a better way.
  • Classic Load Balancer - Such load balancer routes traffic to applications in the Amazon EC2.

We can select a load balancer per our requirements, as AWS fully manages it. You can check this link to know more about load balancer in AWS i.e Elastic Load Balancer.

Conclusion

  • Load balancer is used to distribute the incoming traffic to an application equally among all the application servers running.
  • The user sends a request to the load balancer. Then, the load balancer redirects the request to the application server based on some algorithms. Finally, the server sends the response to the incoming request to the load balancer, which gets redirected back to the client who made the request.
  • There are various algorithms based on which the incoming traffic gets distributed across servers. The two important categories are static load balancing algorithm and dynamic load balancing algorithm.
  • Static load balancing algorithm distributes traffic across the application servers without checking the server state. Dynamic load balancing algorithm, on the other checks the server state first before distributing the traffic.
  • There are two types of load balancing technology, hardware load balancers and software load balancers.
  • Application load balancing, Network load balancing, and global server load balancing are the major types of load balancing.
  • Software load balancers are the most cost-effective approach as they reduce the cost and space required for maintaining hardware appliances.