The Wayback Machine - https://web.archive.org/web/20260111191304/https://www.geeksforgeeks.org/machine-learning/elastic-load-balancer-in-aws/

Elastic Load Balancer in AWS

Last Updated : 10 Jan, 2026

Elastic Load Balancing (ELB) automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, IP addresses, and Lambda functions. It acts as the "front door" for your application, ensuring high availability, fault tolerance, and elasticity.

Core Concepts

  • Listeners: A process that checks for connection requests. You define a protocol (e.g., HTTPS) and a port (e.g., 443).
  • Target Groups: A logical group of backend resources (EC2 instances, Lambda functions, IP addresses). The load balancer routes traffic to a Target Group, not directly to an instance.
  • Health Checks: The ELB periodically pings your targets (e.g., /health). If a target fails, ELB stops sending traffic to it until it recovers.
  • Cross-Zone Load Balancing: Ensures traffic is distributed evenly across all healthy targets in all enabled Availability Zones, preventing one AZ from being overloaded.

Types of Load Balancers

  1. Classic Load Balancer: It is the traditional form of load balancer which was used initially. It distributes the traffic among the instances and is not intelligent enough to support host-based routing or path-based routing. It ends up reducing efficiency and performance in certain situations. It is operated on the connection level as well as the request level. Classic  Load Balancer is in between the transport layer (TCP/SSL) and the application layer (HTTP/HTTPS).
  2. Application Load Balancer: This type of Load Balancer is used when decisions are to be made related to  HTTP and HTTPS traffic routing. It supports path-based routing and host-based routing. This load balancer works at the Application layer of the OSI Model. The load balancer also supports dynamic host port mapping.
  3. Network Load Balancer: This type of load balancer works at the transport layer(TCP/SSL) of the OSI model. It’s capable of handling millions of requests per second.  It is mainly used for load-balancing TCP traffic.
  4. Gateway Load Balancer: Gateway Load Balancers provide you the facility to deploy, scale, and manage virtual appliances like firewalls. Gateway Load Balancers combine a transparent network gateway and then distribute the traffic.

Steps to configure an Application load balancer in AWS

Step 1: Launch the two instances on the AWS management console named Instance A and Instance B. Go to services and select the load balancer. To create AWS free tier account refer to Amazon Web Services (AWS) – Free Tier Account Set up.

Launch Intance

Step 2: Click on Create the load balancer.

Load balancing

Step 3: Select Application Load Balancer and click on Create.

Different load balancers

Step 4: Here you are required to configure the load balancer. Write the name of the load balancer. Choose the scheme as internet facing.

Configure load balancer

 Step 5: Add at least 2 availability zones. Select us-east-1a and us-east-1b

Select the VPC

Step 6: We don't need to do anything here. Click on Next: Configure Security Groups

Configure Security Settings

Step 7: Select the default security group. Click on Next: Configure Routing

Security Groups

Step 8: Choose the name of the target group to be my target group. Click on Next: Register Targets.

Name

Step 9: Choose instance A and instance B and click on Add to register. Click on Next: Review.

Register Targets

Step 10: Review all the configurations and click on create

Review

Step 11: Congratulations!! You have successfully created a load balancer. Click on close.

Load balancer status

Step 12: This highlighted part is the DNS name which when copied in the URL will host the application and will distribute the incoming traffic efficiently between the two instances.

Load Balancer DNS name

Step 13: This is the listener port 80 which listens to all the incoming requests

Listerners

Step 14: This is the target group that we  have created

Create Target Groups

Step 15: Now we need to delete the instance. Go to Actions -> Click on Delete.

Edit subnetes

Step 16: Also don't forget to terminate the instances.

Terminate the Instance

Advantages of Elastic Load Balancer

  • High Availability: Automatically distributes traffic across AZs. If one instance fails, traffic is routed to healthy ones.
  • Elasticity: Automatically scales to handle changes in traffic throughput without manual intervention.
  • Security: Supports SSL/TLS termination (decrypting traffic at the LB) and integrates with AWS WAF.
  • Health Monitoring: Continuously checks the health of backends and routes traffic only to healthy resources.

Disadvantages of Elastic Load Balancer

  • Latency: Adds a small amount of latency (ms) as traffic must pass through the load balancer before reaching the target
  • Cost: Can increase your bill, especially with high data transfer or if you use multiple load balancers unnecessarily.
  • Complexity: Introduces an additional layer to manage and debug (e.g., troubleshooting 502 Bad Gateway errors).
  • Limited Customization: As a managed service, you cannot tweak the underlying OS or network stack of the LB itself.

When to Use Which?

FeatureALBNLB
ProtocolHTTP, HTTPS, gRPCTCP, UDP, TLS
RoutingAdvanced (Path, Host, Headers)Simple (Hash-based)
LatencyLow (~400ms)Ultra-Low (~100ms)
Static IPNo (DNS only)Yes (Per AZ)
Use CaseWebsites, APIs, MicroservicesGaming, Finance, IoT

Pricing Models

ELB pricing is based on two components: an hourly charge and a usage charge (Capacity Units).

Load BalancerHourly ChargeUsage Metric
ALB~$0.0225 / hourLCU (Load Balancer Capacity Units) - Based on new connections, active connections, and bandwidth.
NLB~$0.0225 / hourNLCU (Network Load Balancer Capacity Units) - Based on bandwidth and connections.
GWLB~$0.0125 / hourGLCU (Gateway Load Balancer Capacity Units).
CLB~$0.025 / hourData Transfer (GB).
Comment

Explore