6 min.

Load balancing concepts on AWS

Overview of load balancing and associated services in AWS

AWS offers four primary types of load balancers: Application Load Balancer, Network Load Balancer, Gateway Load Balancer, and the older Classic Load Balancer. These are all part of the Elastic Load Balancing service, which is designed to automatically distribute incoming application traffic across multiple targets.

 

Elastic Load Balancing responds not only to varying traffic volumes but also reroutes traffic based on health check results and user-defined rules. Among its key features is integration with Auto Scaling, allowing the number of Amazon EC2 instances to adjust in response to traffic fluctuations, ensuring that the load balancing environment can dynamically scale with changing demand. 

 

Health checks play a crucial role in determining the health status of the targets, and advanced routing options are available, particularly with Application Load Balancers, for routing requests based on their content. 

 

Additionally, AWS load balancers are deeply integrated within the AWS ecosystem, offering advanced features like security enhancements through AWS WAF and AWS Shield, and operational monitoring using Amazon CloudWatch, further enhancing their functionality and effectiveness in the AWS cloud environment.

 

 

What are key features of ELB in AWS

 

Elastic Load Balancing (ELB) in AWS provides a comprehensive set of features designed to enhance the performance and availability of applications:

 

Efficient Load Distribution

 

Distributes incoming traffic across multiple backends, like EC2 instances in one or many Availabilit Zones, boosting scalability and availability.

 

 

High Performance and Fault Tolerance

 

Manages thousands of requests per second with minimal latency, maintaining consistent performance, especially during peak traffic periods.

 

 

Health Check Mechanism

 

Performs regular health assessments on backend instances, routing traffic only to operational ones to uphold high availability.

 

 

Dynamic Autoscaling

 

Integrates with autoscaling to modify EC2 instance numbers in response to traffic fluctuations, ensuring efficient resource use.

 

Versatile Load Balancing Options

 

Accommodates both internet-facing load balancers for external traffic and internal load balancers for traffic within Virtual Private Clouds (VPCs).

 

 

Layer-Based Routing

 

Supports Application Load Balancers (ALB) for HTTP/HTTPS traffic (layer 7) and Network Load Balancers (NLB) for TCP/UDP traffic (layer 4).

 

 

Cross-Zone Balancing

 

Evenly distributes traffic across multiple Availability Zones, enhancing fault tolerance and load management.

 

 

SSL/TLS Offloading

 

Handles SSL/TLS decryption, reducing the encryption burden on backend instances so you don't need to use Let's encryrpt or buy SSL certificates.

 

 

Session Affinity (Sticky Sessions)

 

Maintains user session continuity by binding sessions to specific instances.

 

 

AWS Service Integration

 

Seamlessly operates with AWS Auto Scaling, CloudWatch, and AWS Certificate Manager.

 

 

Robust Security Features

 

Integrates with AWS WAF and AWS Shield, offering advanced protection against web threats and DDoS attacks.

 

 

Advanced ALB Routing

 

Includes path-based and host-based routing, allowing for precise traffic direction.

 

 

Port-Based NLB Routing

 

Enables multiple applications to run on a single EC2 instance, with each application using a distinct port.

 

 

Operational Monitoring and Logging

 

Provides real-time traffic insights via access logs and CloudWatch metrics.

 

 

Connection Draining

 

Prevents interruption of in-progress requests during instance scaling or maintenance.

 

 

How does ELB work in AWS?

 

Each of the four types of Elastic Load Balancers (ELBs) in AWS, namely Application Load Balancer (ALB), Network Load Balancer (NLB), Classic Load Balancer (CLB), and Gateway Load Balancer (GLB), operates with distinct mechanisms and components suited to their specific use cases. 

 

While ALB and NLB primarily use listeners, target groups, and targets for managing and routing traffic, CLB and GLB have different configurations. CLB, being older, has a simpler setup focusing on EC2 instances as targets and does not use target groups. GLB is unique as it operates at the network layer (Layer 3) and is designed for forwarding traffic to appliances like firewalls and intrusion detection systems

 

Here's how these components work together:

 

Listeners

 

Listeners wait for incoming traffic on the ELB. They are configured with a protocol and a port for connections (for example, HTTP on port 80, or HTTPS on port 443).

 

When a request is received, the listener checks its rules to determine how to route the request. These rules are based on the URL path, hostname, HTTP headers, and other factors for Application Load Balancers (ALBs).

 

 

Target Groups

 

A target group is used to route requests to one or more registered targets, such as EC2 instances, IP addresses, or Lambda functions.

 

In the case of ALBs and Network Load Balancers (NLBs), each listener rule specifies a target group to which traffic should be forwarded.

Target groups also define health check settings. Health checks are used to determine the health status of each target.

 

 

Targets

 

Targets within a target group can be EC2 instances, IP addresses, or Lambda functions that process the requests.

 

The ELB continually checks the health of each target using the configured health checks. If a target is deemed unhealthy, ELB stops sending traffic to it until it becomes healthy again.

 

 

Load Balancer Types

 

Depending on the type of load balancer (ALB, NLB, or Classic Load Balancer), the behavior of listeners and target groups can vary. For instance, ALBs are application-aware and can make advanced routing decisions, while NLBs work at the transport layer and are optimized for high performance and low latency.

 

 

Routing and Load Balancing Algorithm

 

The ELB routes incoming traffic to targets based on the configured rules in the listeners.

It uses load balancing algorithms (like round-robin or least outstanding requests) to efficiently distribute traffic among the targets in a target group.

 

 

Scalability and Availability

 

ELB can automatically adjust and scale according to the incoming traffic.

It also ensures high availability by distributing traffic across multiple targets in different Availability Zones.

 

 

Comparison of AWS Elastic Load Balancers: ALB, NLB, CLB, and GLB

 

FeatureApplication Load Balancer (ALB)Network Load Balancer (NLB)Classic Load Balancer (CLB)Gateway Load Balancer (GLB)
OSI layerLayer 7 (Application layer)Layer 4 (Transport layer)Layer 4 & 7Layer 3 (Network layer)
ProtocolHTTP/HTTPSTCP/UDPTCP/UDP & HTTP/HTTPSIP Traffic
Use CaseAdvanced request routing for web applications, microservices, containersHandling volatile, high-volume traffic, real-time applicationsSimple load balancing for applications built within EC2-Classic networkransparent network gateway for third-party virtual appliances
RoutingContent-based (path, hostname, headers)IP, TCP, UDPLimited, based on protocol or pathIP-based
PerformanceHigh throughput, moderate latencyVery high throughput, low latencyModerate performanceDesigned for third-party virtual appliance throughput
IP Address PreservationNo (uses X-Forwarded-For header)YesNo (uses X-Forwarded-For header)Yes
Target TypeEC2 instances, containers, IP addresses, Lambda functionsEC2 instances, containers, IP addressesEC2 instancesEC2 instances, IP addresses

 

 

References