Photo by Jonathan on Unsplash

Decoding AWS Load Balancers: Application vs Network

Stilia Johny
5 min readMar 21, 2024

--

Load balancers help keep websites running smoothly by managing traffic. AWS has few types which two of the most popular are: the Application Load Balancer (ALB) and the Network Load Balancer (NLB).

They work differently and are used for different things.

In this article, we’ll look at ALB and NLB, explain how they’re different, and help you decide which one is right for your project.

Let’s get started.

Understanding Load Balancers in AWS

Load balancers are essential tools in AWS that help distribute incoming internet traffic across multiple servers to ensure no single server gets overwhelmed. This not only improves the responsiveness of your applications but also increases their availability by preventing server overloads. AWS offers several types of load balancers, with the most prominent being the Application Load Balancer (ALB) and the Network Load Balancer (NLB).

The ALB is best suited for HTTP and HTTPS traffic, offering advanced request routing targeted at delivering modern application architectures, such as microservices and container-based applications. On the other hand, the NLB is designed for high-performance, low-latency TCP traffic, where it routes connections based on IP protocol data.

By effectively utilizing these load balancers, you can ensure your applications run smoothly under varying loads, providing a better experience for your users and safeguarding the reliability of your services in AWS.

What is an Application Load Balancer (ALB)?

An Application Load Balancer (ALB) is a service within Amazon Web Services (AWS) designed to automatically distribute incoming application traffic across multiple targets, such as EC2 instances, containers, and IP addresses, in multiple Availability Zones. ALBs are best suited for handling HTTP and HTTPS traffic, providing advanced routing features that allow for more efficient handling of web traffic patterns.

Key features of an ALB include:

  • Content-Based Routing: ALBs can make routing decisions based on the content of the request. This means it can route requests to different backend services based on the requested URL, hostname, headers, and other criteria.
  • Support for Modern Application Architectures: ALBs are well-suited for applications that are built using microservices or containers. They integrate seamlessly with Amazon ECS (Elastic Container Service), Amazon EKS (Elastic Kubernetes Service), and Lambda functions, providing flexibility in how applications are deployed and managed.
  • High Availability: By operating across multiple Availability Zones, ALBs ensure that the application remains accessible even if one or more servers fail.
  • Listener Rules: ALBs allow you to define rules for listeners, which listen on a port for incoming traffic and then route that traffic according to the defined rules. This provides precise control over traffic routing.
  • SSL/TLS Termination: ALBs handle SSL/TLS termination for your applications, offloading the encryption and decryption process from the application servers and thereby improving performance.

In essence, an Application Load Balancer is designed to offer more control and flexibility in routing application traffic, making it an essential component for deploying scalable and highly available web applications and services on AWS.

What is a Network Load Balancer (NLB)?

A Network Load Balancer (NLB) is part of Amazon Web Services (AWS) that efficiently handles incoming network traffic across multiple targets, such as EC2 instances, in multiple Availability Zones. Unlike the Application Load Balancer (ALB) that focuses on HTTP and HTTPS traffic, the NLB is optimized for high-throughput, low-latency TCP, UDP, and TLS traffic, making it ideal for dealing with sudden and volatile traffic patterns where millisecond latencies are critical.

Key characteristics of an NLB include:

  • Performance: NLB is designed for performance-intensive applications and can handle millions of requests per second while maintaining ultra-low latencies, making it suitable for real-time and gaming applications, as well as TCP or UDP based protocols.
  • Static IP or Elastic IP Support: Unlike ALBs, NLBs allow the assignment of one static IP address per Availability Zone, facilitating the use of whitelisting IP addresses in firewall rules or corporate routing policies.
  • Preservation of Source IP: NLB passes the client’s IP address to the target, which is crucial for applications that need the true IP address of the client for processing requests or for logging purposes.
  • Scalability and High Availability: NLB automatically scales to handle varying load levels and operates across multiple Availability Zones, ensuring high availability and fault tolerance for applications.
  • Zonal Isolation: NLBs route traffic to targets within the same Availability Zone, reducing cross-zone latency and improving efficiency.

In summary, the Network Load Balancer is engineered for applications that require robust handling of TCP/UDP traffic, offering high performance, reliability, and network-level load balancing features. It’s an excellent choice for applications where low latency and high throughput are paramount.

Key Differences Between ALB and NLB

Traffic Type and Routing:

  • ALB is designed primarily for HTTP and HTTPS traffic, offering advanced request-level (Layer 7) routing capabilities, such as routing based on URL path or host field.
  • NLB handles TCP, UDP, and TLS traffic, focusing on efficient routing of connection-level (Layer 4) traffic. It’s optimized for situations where high performance and low latency are critical.

Performance and Latency:

  • ALB provides robust performance with flexibility in HTTP/HTTPS traffic management but introduces a slight latency due to its higher-level processing.
  • NLB is engineered for high-performance and ultra-low latency scenarios, capable of handling millions of requests per second as it operates at the connection level.

IP Address Usage:

  • ALB uses a DNS name and manages traffic across multiple IP addresses, which can change over time.
  • NLB supports static IP addresses for each Availability Zone, making it suitable for applications requiring a consistent IP address for whitelisting or network policies.

Target Health Checks:

  • Both ALB and NLB perform health checks to ensure traffic is only routed to healthy targets, but ALB can perform more advanced checks at the request level (e.g., checking for specific response codes from a web application).
  • NLB performs health checks at the connection level, ensuring the target can accept connections.

Target Type Support:

  • ALB can route traffic to multiple types of targets, including EC2 instances, containers, and IP addresses, and integrates closely with AWS’s Elastic Container Service (ECS) and Elastic Kubernetes Service (EKS).
  • NLB is more focused on routing traffic to EC2 instances and IP addresses but offers the advantage of preserving the original source IP address of the client, which is crucial for certain applications.

Use Cases:

  • ALB is ideal for complex content-based routing in web applications, such as microservices or container-based architectures, where advanced routing, session persistence, and HTTP headers are important.
  • NLB is best suited for high-performance applications where low latency is critical, such as real-time gaming, stock trading platforms, or any TCP/UDP based application needing high throughput and static IP addresses.

Resources

--

--

Stilia Johny
Stilia Johny

Written by Stilia Johny

Loving tech on its entirety, lets talk about electronics, linux, security and best practices!!

No responses yet