Some references need to be understood to comprehend the Types of Load Balancers:
What is an Elastic Load Balancer?
Elastic Load Balancers (ELB) are managed services by AWS that automatically distribute incoming application traffic across multiple EC2 instances, containers, or IP addresses. This ensures your applications can handle high traffic and maintains availability, security, and performance by balancing loads.
Key Concepts
- Load Balancing:
- ELB spreads incoming traffic across multiple targets, which could be EC2 instances or containers.
- This load distribution helps prevent any single server from becoming overwhelmed.
- Types of Load Balancers:
- Application Load Balancer (ALB): Works at the application layer (Layer 7) and routes requests based on content, such as URL paths, making it suitable for HTTP and HTTPS traffic.
- Network Load Balancer (NLB): Operates at the transport layer (Layer 4), handling large volumes of TCP or UDP traffic quickly and efficiently. It's ideal for latency-sensitive applications.
- Gateway Load Balancer (GLB): Primarily used to distribute traffic to security appliances like firewalls and intrusion detection systems.
- Classic Load Balancer (CLB): An older, simpler version used mainly for Layer 4 and Layer 7 traffic, but now largely replaced by ALB and NLB.
- Health Checks:
- ELBs regularly check the health of targets (instances or containers) to make sure they can handle requests. If an unhealthy target is found, traffic is automatically routed to healthy targets.
- Sticky Sessions:
- For applications that need to "stick" users to the same server (like for shopping carts), ELB supports sticky sessions, keeping users connected to the same target for a consistent experience.
Important Points
- Automatic Scaling: ELBs work well with Auto Scaling Groups (ASG) by dynamically directing traffic to new instances added by ASG as demand increases.
- Cross-Zone Load Balancing: This feature distributes traffic evenly across instances in different Availability Zones, increasing application resilience.
- SSL Termination: ELB can manage SSL certificates and handle SSL termination to reduce the load on application servers.
Best Used For
- High Availability and Fault Tolerance: Distributes traffic across multiple instances, so if one fails, others can handle the load.
- Applications with Variable or High Traffic: Balances traffic efficiently and works with ASG to meet fluctuating demand.
- Layer-Specific Traffic Management: Choose ALB for applications with complex routing needs, or NLB for low-latency applications.
Best Practices
- Enable Cross-Zone Load Balancing for more even traffic distribution, especially if you have targets in multiple zones.