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.
Types of Load Balancers
| Type | OSI Layer | Protocols | Best For |
|---|---|---|---|
| Application Load Balancer (ALB) | Layer 7 (Application) | HTTP, HTTPS | Content-based routing, microservices, container-based applications |
| Network Load Balancer (NLB) | Layer 4 (Transport) | TCP, UDP, TLS | Millions of requests per second, ultra-low latency, volatile traffic patterns |
| Gateway Load Balancer (GWLB) | Layer 3 (Network) | All IP packets | Virtual 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.