Demystifying AWS Load Balancers: Understanding Elastic, Application, Network, and Gateway Load Balancers

Ajay Verma
AWS in Plain English
7 min readMar 21, 2024

--

In the realm of cloud computing, load balancing plays a crucial role in distributing incoming traffic across multiple targets to ensure high availability, fault tolerance, and scalability of applications. In the high-traffic world of cloud applications, ensuring smooth operation and optimal performance requires a skilled conductor — the load balancer. AWS offers a robust suite of load balancers, each catering to specific needs. Amazon Web Services (AWS) offers a suite of load balancers tailored to different use cases and requirements. In this blog, we’ll delve into the distinctions between AWS Elastic Load Balancer (ELB), Application Load Balancer (ALB), Network Load Balancer (NLB), and Gateway Load Balancer (GWLB), exploring their features, examples, and dissimilarities. Additionally, we’ll shed light on the flow hash algorithm used by AWS load balancers to route traffic efficiently.

The Balancing Act: What They Do

At their core, all these load balancers perform the same essential function: distributing incoming traffic across a pool of resources, ensuring no single server gets overwhelmed. This enhances application availability and responsiveness for your users.

1. Elastic Load Balancer (ELB):

  • Description: AWS Elastic Load Balancer (ELB) is the original load balancer service offered by AWS, providing basic traffic distribution across multiple targets within a single AWS region. It is a simple and cost-effective way to distribute traffic across multiple EC2 instances. ELB supports both HTTP and TCP traffic.
  • Example: Distributing incoming traffic across multiple EC2 instances running web servers to ensure high availability and fault tolerance for a web application.

Features:

  • Simple to configure and manage
  • Supports HTTP and TCP traffic
  • Can be used to distribute traffic across multiple EC2 instances
  • Offers a variety of features, including health checks, sticky sessions, and SSL termination.

Use Cases:

  • Distributing traffic to web servers
  • Load balancing for TCP applications, such as databases and mail servers
  • Providing SSL termination for web applications

2. Application Load Balancer (ALB):

  • Description: AWS Application Load Balancer (ALB) operates at the application layer (Layer 7) of the OSI model, enabling advanced routing and content-based routing capabilities. ALB is a newer type of load balancer that is designed for modern applications. It offers a number of features that are not available in ELB, such as support for HTTP/2, WebSockets, and container-based applications. it’s inspecting incoming requests based on factors like HTTP headers, path, or cookies. This allows for intelligent routing based on application logic. For instance, an ALB can direct traffic to a specific server based on the user’s location or the type of request.
  • Example: Routing traffic based on URL paths or hostnames to different backend services, such as directing /api requests to a set of API servers and /app requests to web servers.

Features:

  • Supports HTTP/2, WebSockets, and container-based applications
  • Offers a variety of features, including health checks, sticky sessions, and SSL termination
  • Can be used to distribute traffic across multiple EC2 instances, containers, and Lambda functions

Use Cases:

  • Load balancing for web applications
  • Distributing traffic to microservices
  • Load balancing for container-based applications

3. Network Load Balancer (NLB):

  • Description: AWS Network Load Balancer (NLB) operates at the transport layer (Layer 4) of the OSI model, offering ultra-low latency and high throughput for TCP and UDP traffic. NLB is a high-performance load balancer that is designed for use with TCP applications. It offers very low latency and high throughput. This prioritizes speed and efficiency, making it ideal for high-volume, low-latency applications like gaming servers or chat platforms.
  • Example: Load balancing traffic for TCP-b ased services such as databases, FTP servers, and gaming applications that require high performance and minimal overhead. NLB is ideal for applications that require low latency, such as gaming, financial trading, and video streaming.

Features:

  • Very low latency and high throughput
  • Supports TCP traffic
  • Can be used to distribute traffic across multiple EC2 instances
  • Offers a variety of features, including health checks and sticky sessions

Use Cases:

  • Load balancing for TCP applications, such as gaming, financial trading, and video streaming
  • Distributing traffic to EC2 instances that are running in a VPC

4. Gateway Load Balancer (GLB):

  • Description: The GLB is a versatile player, operating across layers 3 (network layer) and 7 (application layer). It acts as a central gateway for managing virtual appliances like firewalls or intrusion detection systems. It balances traffic across these appliances while maintaining secure communication through VPC endpoints. AWS Gateway Load Balancer (GLB) is designed for deploying, scaling, and managing third-party virtual appliances such as firewalls, intrusion detection systems (IDS), and encryption appliances. GLB is a load balancer that is designed for use with VPC endpoints. It allows you to load balance traffic to endpoints in a private VPC. GLB is ideal for applications that require access to private resources, such as databases and internal APIs.
  • Example: Deploying a third-party firewall appliance to inspect and filter traffic between VPCs or between on-premises networks and the AWS cloud.

Features:

  • Load balances traffic to endpoints in a private VPC
  • Supports HTTP and TCP traffic
  • Can be used to distribute traffic across multiple endpoints
  • Offers a variety of features, including health checks and sticky sessions

Use Cases:

  • Load balancing for applications that require access to private resources
  • Distributing traffic to endpoints in a private VPC

Similarities: A United Front

  • High Availability: All load balancers ensure that even if individual instances fail, traffic seamlessly flows to healthy ones, keeping your application up and running.
  • Scalability: They automatically adjust to traffic fluctuations, scaling resources up or down as needed.
  • Health Monitoring: They constantly monitor the health of target instances and remove unhealthy ones from the pool.

Dissimilarities:

  • Layer of Operation: ALB operates at Layer 7 (application layer), allowing for content-based routing, while NLB operates at Layer 4 (transport layer), focusing on routing traffic based on IP addresses and ports.
  • Performance Characteristics: NLB offers ultra-low latency and high throughput for TCP and UDP traffic, making it ideal for high-performance applications, whereas ALB provides advanced routing features and supports WebSocket and HTTP/2 protocols.
  • Use Cases: ALB is suitable for modern application architectures, microservices, and container-based environments, while NLB is preferred for TCP-based workloads requiring high performance and minimal overhead.
  • Routing Intelligence: ALBs excel in application-level routing, while NLBs prioritize speed and efficiency.
  • Supported Protocols: ALBs handle HTTP/HTTPS traffic, while NLBs work with TCP/UDP protocols.
  • Virtual Appliance Management: GLBs are specifically designed for managing and scaling virtual appliances.

The following table summarizes the key dissimilarities between the four types of AWS load balancers:

dissimilarities between the four types of AWS load balancers

Flow Hash Algorithm: The flow hash algorithm is used by AWS load balancers to distribute incoming traffic across multiple targets while maintaining session affinity for stateful protocols. The flow hash algorithm calculates a hash value based on specific attributes of each incoming request, such as source IP address, destination IP address, source port, destination port, and protocol. This hash value is then used to determine which target receives the incoming request. The flow hash algorithm takes into account the source IP address, destination IP address, and destination port of each request. This ensures that requests from the same client are always sent to the same target.

The flow hash algorithm is a very effective way to distribute traffic evenly across multiple targets. It is also very efficient, as it does not require any additional overhead.

It takes a portion of the data flow (like source and destination IP addresses, ports) and generates a hash value. Based on this hash, the load balancer directs traffic to a specific instance. This ensures even distribution and prevents overloading individual instances.

Examples

Example 1: Load balancing a web application

You can use an ALB to load balance traffic to a web application that is running on multiple EC2 instances. The ALB will distribute traffic evenly across the instances and will ensure that requests from the same client are always sent to the same instance.

Example 2: Load balancing a TCP application

You can use an NLB to load balance traffic to a TCP application that is running on multiple EC2 instances. The NLB will provide very low latency and high throughput, making it ideal for applications that require low latency, such as gaming, financial trading, and video streaming.

Example 3: Load balancing traffic to a private VPC

You can use a GLB to load balance traffic to a private VPC. This allows you to load balance traffic to endpoints in a private VPC, such as databases and internal APIs.

Choosing the Right Load Balancer: It All Depends

Selecting the optimal load balancer hinges on your application’s unique requirements:

  • ALB: Ideal for web applications requiring intelligent routing based on application logic.
  • NLB: Perfect for high-performance applications that prioritize speed and low latency.
  • GLB: The go-to choice for managing and scaling virtual appliances within your network.

Conclusion: AWS offers a range of load balancing options, each tailored to different use cases and requirements. By understanding the distinctions between Elastic Load Balancer (ELB), Application Load Balancer (ALB), Network Load Balancer (NLB), and Gateway Load Balancer (GWLB), you can choose the right load balancing solution to optimize the performance, availability, and scalability of your applications in the AWS cloud. Additionally, the flow hash algorithm employed by AWS load balancers ensures efficient traffic distribution while maintaining session affinity, further enhancing the reliability and performance of your application deployments.

When choosing a load balancer, it is important to consider the following factors:

  • The type of traffic that you need to load balance
  • The latency and throughput requirements of your application
  • The features that you need

By considering these factors, you can choose the right load balancer for your application and ensure that your traffic is distributed evenly and efficiently.

In Plain English 🚀

Thank you for being a part of the In Plain English community! Before you go:

--

--

Data Analyst | 6 Sigma Master Black Belt | NLP | GenAI | Data Scientist | Ex-IBM | Ex-Accenture | Ex-Fujitsu. https://www.linkedin.com/in/ajay-verma-1982b97/