AWS Elastic Load Balancing (ELB)
Elastic Load Balancing (ELB) is the AWS service that automatically distributes incoming traffic across multiple targets, such as EC2 instances, containers and IP addresses, in one or more Availability Zones. It checks the health of the targets and sends requests only to the healthy ones, so a failed instance does not interrupt the service.
Types of load balancers #
| Type | Layer | Typical use |
|---|---|---|
| Application Load Balancer (ALB) | 7 (HTTP, HTTPS, gRPC) | Web sites and APIs. Routing by host, path, header or query string, redirects, HTTPS termination |
| Network Load Balancer (NLB) | 4 (TCP, UDP, TLS) | Very high throughput and low latency, static IP addresses per Availability Zone |
| Gateway Load Balancer (GWLB) | 3 | Firewalls and traffic inspection appliances |
| Classic Load Balancer | 4 and 7 | Previous generation, kept for old applications |
Key concepts #
- Listener: the protocol and port the load balancer listens on (for example HTTPS 443) and the rules that decide what to do with each request.
- Target group: the set of targets that receive the traffic and the health check that decides which are healthy.
- Cross-zone load balancing: distributes requests evenly between the targets of all the enabled zones.
- A load balancer lives in at least two public (internet-facing) or private (internal) subnets, and is protected with security groups.
- HTTPS certificates come from AWS Certificate Manager. AWS WAF can be attached to an ALB.
Pricing #
Billed per hour that the load balancer runs plus the capacity used (Load Balancer Capacity Units, or Network Load Balancer Capacity Units). See the Elastic Load Balancing pricing.
With Terraform #
The resources are aws_lb, aws_lb_target_group, aws_lb_listener and aws_lb_listener_rule.
See tutorials:
- AWS with Terraform: The Essential Guide (16/21) – AWS Load Balancers
- Terraform AWS EKS Cluster Deployment & Application Publishing through ALB
See also: AWS Auto Scaling, AWS Route 53.