Lesson 42

Elastic Load Balancing

Application, Network, and Gateway Load Balancers — distributing traffic for high availability

1. Why Scaling Matters

Scaling is the ability to increase or decrease the compute capacity of your application based on demand. Without automatic scaling, you face a capacity dilemma:

  • Over-provision — You allocate enough capacity for peak demand, but resources sit idle most of the time. Costs are not optimized.
  • Under-provision — You allocate less capacity to save money, but your application underperforms or becomes unavailable during traffic spikes.

In the cloud, computing power is a programmatic resource. You can take a flexible approach to scaling by using services that automatically respond to changes in demand.

2. Elastic Load Balancing

Elastic Load Balancing (ELB) is an AWS service that distributes incoming application or network traffic across multiple targets in a single Availability Zone or across multiple Availability Zones. It scales your load balancer automatically as traffic changes over time.

ELB Targets: EC2 instances, containers, IP addresses, and Lambda functions.

Types of Load Balancers

TypeOSI LayerProtocolsBest For
Application Load Balancer (ALB)Layer 7 (Application)HTTP, HTTPSContent-based routing, microservices, container-based applications
Network Load Balancer (NLB)Layer 4 (Transport)TCP, UDP, TLSMillions of requests per second, ultra-low latency, volatile traffic patterns
Gateway Load Balancer (GWLB)Layer 3 (Network)All IP packetsVirtual appliances such as firewalls, intrusion detection, deep packet inspection

How ELB Works

  • A listener checks for connection requests. It is configured with a protocol and port number for connections from clients to the load balancer, and from the load balancer to the targets.
  • You register targets in target groups and route traffic to those groups.
  • The load balancer performs health checks on registered targets. It routes traffic only to healthy targets. If a target becomes unhealthy, traffic stops until the target recovers.

ELB Use Cases

  • High availability and fault tolerance — Traffic is balanced across healthy targets in multiple Availability Zones. If targets in one AZ become unhealthy, traffic routes to targets in other AZs.
  • Containerized applications — Deep integration with Amazon ECS. You register a service with a load balancer, and ECS transparently manages container registration and deregistration.
  • Automatic scaling — ELB works with Amazon CloudWatch and EC2 Auto Scaling to scale applications to meet customer demand.
  • VPC entry point — Create a public or internal load balancer within your VPC. An internal load balancer does not need an internet gateway.
  • Hybrid environments — Load balance across AWS and on-premises resources using the same load balancer.
  • Invoke Lambda functions — Register Lambda functions as targets with an Application Load Balancer to serve HTTP(S) requests.

Monitoring Load Balancers

  • Amazon CloudWatch metrics — ELB publishes metrics to CloudWatch. You can create alarms that initiate actions when metrics go outside acceptable ranges.
  • Access logs — Capture detailed information about requests sent to your load balancer and store them in Amazon S3.
  • AWS CloudTrail logs — Capture detailed information about API calls made to the ELB API, stored in Amazon S3.

Elastic Load Balancing Quiz

Select one answer per question. You will receive immediate feedback.

1. Which load balancer type operates at OSI Layer 7 and is best for routing HTTP traffic to microservices based on the content of the request?
2. A company needs to deploy third-party firewall virtual appliances across multiple Availability Zones. Which load balancer type should they use?
3. Which load balancer type is optimized to handle sudden and volatile traffic patterns while maintaining ultra-low latencies?
4. Which ELB component checks for connection requests and is configured with a protocol and port number?
5. An e-commerce site expects 10x traffic during a flash sale. They need to distribute millions of HTTPS requests across thousands of EC2 instances. Which pair of services should they use?
Progress: 0/5 correct (0%). Answer all questions to see the final recommendation.
Primary Source: AWS Academy Module 10: Automatic Scaling and Monitoring — Elastic Load Balancing.
Last updated: June, 2026© 2026 Shahriar Ahmed ShovonCredits