AWS Load Balancing Overview
- Definition: A load balancer is a server or a set of servers that distribute incoming network traffic across multiple backend EC2 instances.
- Purpose: It ensures that no single server bears too much demand. By spreading the load, it increases the application's responsiveness and availability.
Key Points
- Elastic Load Balancer (ELB): A set of servers that manage the incoming traffic and distribute it to EC2 instances.
- User Transparency: Users connect to the ELB rather than directly to backend instances, unaware of which instance is serving them.
- Benefits of Using Load Balancers:
- Spreads load across multiple instances.
- Provides a single point of access to applications.
- Handles failures of instances seamlessly with health checks.
- Offers SSL termination for secure HTTPS traffic.
- Enforces stickiness with cookies.
- Ensures high availability across zones.
- Separates public and private traffic.
AWS Managed Load Balancers
- Managed Service: AWS handles upgrades, maintenance, and availability.
- Cost-Effective: Cheaper than setting up a personal load balancer.
- Scalability: Automatically scales with traffic.
- Integration: Works with EC2, Auto Scaling groups, ECS, Certificate Manager, CloudWatch, Route 53, WAF, Global Accelerator, etc.
Health Checks
- Function: Determines if an EC2 instance is functioning correctly.
- Mechanism: Uses a specified port and route (e.g.,
/health) to check the instance.
- Response Handling: If an instance fails to return a 200 OK status, it is marked unhealthy and won't receive traffic.
Types of Load Balancers
- Classic Load Balancer (CLB): Older generation, supports HTTP, HTTPS, TCP, SSL/TLS. AWS recommends against using CLB.
- Application Load Balancer (ALB): Supports HTTP, HTTPS, WebSocket. Recommended for modern applications.
- Network Load Balancer (NLB): Supports TCP, TLS, UDP. Suitable for high-performance networking.