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
- 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).
- 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.
- 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.
- 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.

Step 2: Click on Create the load balancer.

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

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

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

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

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

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

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

Step 10: Review all the configurations and click on create

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

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.

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

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

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

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

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?
| Feature | ALB | NLB |
|---|---|---|
| Protocol | HTTP, HTTPS, gRPC | TCP, UDP, TLS |
| Routing | Advanced (Path, Host, Headers) | Simple (Hash-based) |
| Latency | Low (~400ms) | Ultra-Low (~100ms) |
| Static IP | No (DNS only) | Yes (Per AZ) |
| Use Case | Websites, APIs, Microservices | Gaming, Finance, IoT |
Pricing Models
ELB pricing is based on two components: an hourly charge and a usage charge (Capacity Units).
| Load Balancer | Hourly Charge | Usage Metric |
| ALB | ~$0.0225 / hour | LCU (Load Balancer Capacity Units) - Based on new connections, active connections, and bandwidth. |
| NLB | ~$0.0225 / hour | NLCU (Network Load Balancer Capacity Units) - Based on bandwidth and connections. |
| GWLB | ~$0.0125 / hour | GLCU (Gateway Load Balancer Capacity Units). |
| CLB | ~$0.025 / hour | Data Transfer (GB). |

