Elastic Load Balancing (ELB)

Learn via video courses

Overview

Multiple servers are deployed with the same application to avoid server crashes due to an overload of traffic requests. Load Balancers work to distribute this incoming traffic equally among the servers. Elastic Load Balancing is an AWS Service which is used to distribute traffic among the target servers equally automatically. The Target Servers can be EC2 instances or containers or even IP addresses of some servers running on the local machine.

What is Elastic Load Balancing (ELB)?

Elastic Load Balancing is the service provided by AWS which distributes the network traffic to improve the application's functionality. This is a load-balancing service that is fully managed by AWS. It provides user authentication, integrated certificate management, and SSL/TLS decryption to our application for better security.

elastic load balancing logo

Elastic Load Balancing helps the creator of the application monitor the full health and performance of the app in real-time. It automatically distributes the incoming traffic across multiple servers on other EC2 instances, containers, and IP addresses in the same or different availability zone of AWS.

Elastic Load Balancing works with different AWS services to make it more available and scalable.

  • It works with EC2 Auto Scaling, Amazon EC2, Amazon ECS, AWS Global Accelerator to make it more scaleable.
  • It works with Amazon CloudWatch to monitor the action and take decisions according to the situation, like updating, adding, or removing.
  • AWS Certificate Manager, AWS WAF services provides security to the elastic load balancing.

How Does It Work?

AWS ELB distributes incoming user requests across the target instances of the availability zones.

  • The requests are generated by users trying to use an application. Load balancers accept these requests.
  • The load balancers accept the requests and redirect them to target instances which can be an AWS EC2 instance, containers, or on-premises servers.
  • The target EC2 instances can be present in one or more AWS availability zones.
  • Apart from redirecting incoming traffic to the target, it also performs health checks on the target server to ensure the incoming requests are redirected to healthy servers to provide a better user experience.
  • If the load balancer finds any target server in an unhealthy state, it stops sending requests to that particular target server.

We can understand the entire working process of the AWS load balancer with the help of the following diagram given below:

working process of AWS load balancer

  • We have a source that tries to connect to the application server using various protocols.
  • The load balancer accepts the incoming requests to redirect them to target servers.
  • The Elastic Load balancers integrate with other AWS services like AWS Cognito, AWS Certificate Manager, AWS WAF, etc., to enhance security and flexibility.
  • The AWS ELB routes the incoming requests to the target servers after checking their health.
  • The target can be a normal AWS EC2 Instance or container-based AWS ECS, etc.

Features of Elastic Load Balancing

Let's discuss the features of Elastic Load Balancing.

Security

AWS provides security groups associated with Elastic Load Balancing to provide security and networking features to the load balancers. We can create a load balancer for the users with public IP and a load balancer without public IP, which acts as an internal load balancer.

High Availability and Throughput

Elastic Load Balancer easily distributes traffic across EC2 instances in the same or different availability zones, which makes it highly available. In addition, it is designed in such a way that it can handle millions of requests and handle sudden volatile traffic changes.

Health Checks

One of the features of Elastic Load Balancing is that it routes traffic to healthy targets. EC2 instances, containers, Lambda functions are few healthy target which are used by them. Health checks provide insight into the code. It detects the error in the code, allows configuring the error codes, and allows monitoring of the service used by the load balancer.

Sticky Sessions

A sticky session is a mechanism in which requests of a specific client are always routed to the same target. It is supported by elastic Load balancing. So we have to define stickiness at the target group level.

Operational Monitoring & Logging

AWS provides the feature of monitoring the request counts, error counts, error types, request latency of the Application, and Classic Load Balancer using the Amazon CloudWatch. This service also counts Active Flow Count, New Flow Count, Processed Bytes of the network, and gateway load balancer. We can also track API calls to the Elastic Load Balancer using the AWS CloudTrail service.

Delete Protection

AWS load balancer or Elastic Load Balancer provides the feature of delete protection by which we can prevent the load balancer from accidentally being deleted. Therefore, we have to enable the Delete Protection feature.

Types of Load Balancing

We have three significant types of elastic load balancers. Let's discuss each of them in detail.

Classic Load Balancer

  • These load balancers are used in AWS EC2-classic instances.
  • The classical load balancer does not provide a facility for host-based or path-based traffic routing.
  • It works to route the traffic to every target in the given availability zones. The decision to route the traffic is taken in the application layer or transport layer.
  • To route the traffic, we need to have a fixed connection between the container instance port and the load balancer port.

route between container instance port and load balancer

Network Load Balancer

  • It is generally used for routing traffic based on TCP protocols. It is capable of supporting both elastic IP and static IP.
  • In Network Load Balancers, the routing decisions are made in the transport layer of the OSI layer.
  • It is capable of handling the sudden rise in traffic. Let us take an example to understand this. Suppose you have an application running. Overnight, the application went viral for some reason. In such cases, the number of requests will exponentially increase, and network load balancers can handle these situations.

network load balancer routing

Application Load Balancer

  • The routing decisions are taken in the application layer of the OSI model while using Application load balancers.
  • Unlike classic load balancer, it provides path-based and host-based routing support.
  • It works in a slightly different way. First, it analyzes the packets of incoming traffic. Then, it assigns the server with resources available based on the demand of the packet.

application load balancer routing

Gateway Load Balancer

  • Gateway load balancer is used to distribute incoming traffic across multiple application servers via a single gateway.
  • It provides the flexibility to scale the number of application servers up or down depending on the need.
  • It has the capability to work with and manage third-party virtual appliances.

ELB Components

The AWS Elastic Load Balancer comprises three main components.

Load Balancer

  • Load Balancer distributes the incoming user requests across multiple target servers.
  • It aims to increase the availability of the application.
  • Multiple listeners can be added to load balancers.

Listener Instance

  • Listeners verify the incoming user requests using ports and protocols. The ports and protocols match the ones configured for our application server.
  • Only if the two checkpoints (ports and protocols) match, then the request be redirected to the application servers, which are the target.

Target Groups

  • After Listeners check the conditions, the requests must be redirected to some target instances.
  • These target instances can be in the form of an application that serves common requests which form the target groups.

ELB Use Cases

Let's discuss the use cases of ELB.

Application Modernisation

  • Using AWS Elastic load balancer, the need to configure complex API Gateways is reduced.
  • We can have our application running in serverless mode, which can be connected to the elastic load balancer, and the traffic can be easily redirected.
  • AWS ELB supports containers and serverless architecture, which makes managing applications easy and cost-efficient.

Scalability and Hybrid Cloud Network

  • While configuring the AWS load balancer, we can provide the IP address of the target server, and our application can receive user requests.
  • The IP address provides a flexible option, as we can connect to application servers running on other cloud provider services, thus supporting hybrid cloud architecture.
  • Scaling is also a lot easier as a new target can be added anytime to the AWS load balancer. This target can be any serverless application or container-based target.

Retain Existing Network Appliance

  • You can make use of your existing network configurations and resources.
  • The existing network can be further enhanced and scaled using the AWS load balancer, i.e., AWS Elastic Load Balancer.
  • Integration with AWS ELB provides the existing network appliances greater security, flexibility, and high performance.

ELB Pricing

We have four different types of AWS load balancers or AWS ELB. As per the AWS charges policy, AWS ELB follows the pay-as-you-go model. Under this, you are charged only for what you use. Therefore, the billing depends on the number of resources used and the time for each resource.

Application Load Balancer

  • You need to pay for the number of hours/ partial hours the Application load balancer runs.
  • The charges vary from region to region. For example, $0.028125 is incurred for each Application Load Balancer per hour for the US East (Atlanta) region.
  • Charges are also incurred for each Load Balancer Capacity Unit (LCU) used per hour.
  • $0.01 is charged for each LCU per hour for US East (Atlanta) region. This cost varies from one region to another.

Network Load Balancer

  • You need to pay for the number of hours/ partial hours the Network load balancer runs.
  • The charges vary from region to region. For example, a charge of $0.0277 is incurred for each Network Load Balancer being used per hour for the Asia Pacific (Hong Kong) region.
  • Charges are also incurred for each Network Load Balancer Capacity Unit (NLCU) used per hour.
  • $0.0066 is charged for each NLCU per hour for the Asia Pacific (Hong Kong) region. This cost varies from one region to another.

Gateway Load Balancer

  • You need to pay for the number of hours/ partial hours the Gateway load balancer runs.
  • The charges vary from region to region. For example, a charge of $0.0154 is incurred for each Gateway Load Balancer being used per hour for the Asia Pacific (Hong Kong) region.
  • Charges are also incurred for each Gateway Load Balancer Capacity Unit (GLCU) used per hour.
  • $0.0044 is charged for each GLCU per hour for the Asia Pacific (Hong Kong) region. This cost varies from one region to another.
  • Gateway Load Balancer Endpoint is used by the Gateway load balancer, which has a separate billing pattern. Check the pricing of Gateway Load Balancer Endpoint here.

Classic Load Balancer

  • You need to pay for the number of hours/ partial hours the Classic load balancer runs.
  • The charges vary from region to region. For example, a charge of $0.0308 is incurred for each Classic Load Balancer being used per hour for the Asia Pacific (Hong Kong) region.
  • Extra charges are involved for each GB of data transferred via the load balancer.
  • $0.0088 is charged for each GB of data transferred across the load balancer for the Asia Pacific (Hong Kong) region. This cost varies from one region to another.

Getting Started with Elastic Load Balancing

Let's know the process to get started with ELB with the management console.

  • Login to the AWS console after creating an account. aws console login
  • Create a load balancer by selecting Application or network load balancer. create load balancer by application load balancer
  • Specify a unique name and network for the load balancer. unique name and network for load balancer
  • Create the listener endpoints for the load balancer(i.e. HTTP, HTTPS or TCP, UDP) listener endpoints for load balancer
  • Configure the health check for the load balancer and create the load balancer. configure health check for load balancer
  • After that, we can either manually attach EC2 instances to the Target Group and then attach that group with the load balancer, or we can associate the load balancer with an Auto Scaling group. load balancer with auto scaling group

This is a brief view of getting started with AWS load balancer i.e. Elastic Load Balancing.

For the detailed demo, follow the given links:

  • For creating an Application Load Balancer using the AWS Management Console, go through this link.
  • For creating an Application Load Balancer using the AWS CLI, go through this link.
  • For creating a Network Load Balancer using the AWS Management Console, go through this link.
  • For creating a Network Load Balancer using the AWS CLI, go through this link.
  • For creating a Gateway Load Balancer using the AWS Management Console, go through this link.
  • For creating Gateway Load Balancers using the AWS CLI, go through this link.

Benefits of Elastic Load Balancing

Let's look into some of the advantages of using Elastic Load Balancer.

High Availability

  • AWS Elastic Load Balancers can be integrated into any EC2 instance globally, in any availability zone of your choice. Not only this, you can even set up your AWS ELB server across any AWS region.
  • Elastic Load Balancers, an AWS service, have an SLA (Service Level Agreement) of 99.99%.

Hybrid Load Balancing

  • You can integrate the AWS load balancers with any other AWS service/AWS infrastructure. You can also connect it with a local on-premises setup.
  • Moreover, you can integrate it with servers running on other cloud servers, as it takes only an IP address to connect with the target server, easing your task.

Monitoring and Auditing

  • The health check of the application servers is taken care of by the AWS load balancers, with the help of AWS Cloudwatch and other AWS services, which maintain and monitor log files.
  • The logs help analyze the application's behavior, issues encountered, and performance bottlenecks.

Secure and Flexible

  • Load balancing in AWS is highly secure as we can integrate AWS ELB (Elastic Load Balancer) with AWS VPC (Virtual Private Cloud).
  • AWS VPC allows us to decide the incoming and outgoing traffic rules, which increases security. This takes care of encryption-decryption and authentication users. In addition, it also includes certificate management.
  • The target servers for AWS load balancers can be set to any IP address making it highly flexible.

Highly Scalable

  • AWS ELB is capable of handling a sudden increase in traffic. It can handle millions of requests per second.
  • It also provides auto-scaling, which increases the number of running application servers to handle more traffic.

ELB vs. ALB vs. NLB

Let's see the different load balancer features of ELB, ALB, and NLB.

FeatureELBALBNLB
Load Balancer typeLayer 4/7Layer 7Layer 4
Target typeIP, instance, lamda function,etcIP, instance, lamda functionIP, instance
Protocol lisentersTCP, SSL/TLS, HTTP, HTTPSHTTP, HTTPS, gRPCTCP, UDP, TLS
Terminate flow/proxy behaviourYesYesYes
Suppported platformsVPC, EC2-ClassicVPCVPC
Health ChecksTCP,HTTP,HTTPS,SSL/TLSHTTP,HTTPS,gRPCTCP,HTTP,HTTPS

Conclusion

  • Load balances distribute incoming network traffic across multiple application servers to improve user experience.
  • AWS provides a dedicated service for load balancing known as Elastic Load Balancer. ELB works as a load balancer distributing traffic across application servers.
  • The users generate requests for connecting to the application servers. These requests are accepted by AWS ELB, which redirects the requests to target instances. The target instance can be an AWS EC2 instance, container-based AWS ECS, serverless application, or on-premises application servers.
  • AWS load balancer checks the health of the applications servers before forwarding the user requests.
  • Application load balancer, Network load balancer, Gateway load balancer, and Classic load balancer are the significant types of AWS ELB.
  • ELB comprises three significant components load balancers, listener instances, and target groups.
  • It follows the pay-as-you-go model. Charges are incurred for each hour the load balancer runs. The charges vary from one region to another.