What’s the Difference Between Application, Network, and Gateway Load Balancing?


What’s the difference between application, network, and gateway load balancing?

Application load balancer (ALB), network load balancer (NLB), and gateway load balancer (GLB) are three types of load balancers used in the cloud. Load balancing is the process of distributing network traffic equally across a pool of resources supporting an application. Modern applications process millions of users simultaneously. These high-traffic volumes require many resource servers with duplicate data. To redirect application traffic, ALBs examine the requested content, such as HTTP headers or SSL session IDs. NLBs examine IP addresses and other network information to redirect traffic optimally. GLBs act as a transparent network gateway (a single entry and exit point for all traffic) and distribute traffic while scaling your virtual appliances with the demand.

Read about load balancing

How they work: ALB vs. NLB vs. GLB

ALBs, NLBs, and GLBs all provide different functions. Because of this, they work in slightly different ways and include distinct components. 

How an application load balancer works

ALBs distribute incoming traffic across multiple targets, such as EC2 instances. For example, an ecommerce application has a product directory, a shopping cart, and checkout functions. The ALB sends requests for browsing products to servers that contain images and videos but don’t need to maintain open connections. By comparison, it sends shopping cart requests to servers that maintain many client connections and save cart data for a long time.

The ALB has a listener component that checks for connection requests from clients. You can define rules for a listener that determine how the load balancer routes requests to its registered targets. A target group sorts registered targets into groups. You can define rules to route common traffic to an entire group. For example, you can create a target group for general requests and other target groups for requests to the microservices for your application.

The following diagram shows how an ALB works.

How a network load balancer works

NLBs distribute traffic based on network conditions. For example, if you have multiple database servers with duplicate data, the NLB routes traffic based on predetermined server IP addresses or server availability.

The NLB monitors the health of its registered targets and routes traffic only to the healthy targets. After the load balancer receives a connection request, it selects a target from the target group for the default rule. It attempts to open a TCP connection to the selected target on the port specified in the listener configuration. Each individual TCP connection is routed to a single target for the life of the connection. Similarly, you can also route a UDP flow consistently to a single target throughout its lifetime. 

How a gateway load balancer works

With a GLB, you can deploy, manage, and scale virtual appliances, such as intrusion detection and prevention, firewalls, and deep packet inspection systems. It creates a single entry and exit point for all appliance traffic and scales your virtual appliances with demand. You can also use it to exchange traffic across virtual private cloud (VPC) boundaries. 

In the GLB, you establish rules using route tables. Depending on the rules that you set up, it selects different target groups to forward traffic to. It receives IP packets and forwards traffic to specific target groups.

Key differences: ALB vs. NLB vs. GLB

ALBs, NLBs, and GLBs operate at different layers of your network communication. An ALB operates on OSI layer 7 and allows for application-level traffic manipulation and routing. An NLB operates on layer 4 for network-level traffic management based on ports and IP addresses. A GLB works across layers 3 and 7, providing balancing and routing services at the network level along with gateway functionality.

Read about the OSI model

Here are other key differences between ALBs, NLBs, and GLBs.

Target types

The target type is the endpoint that each of these load balancers routes traffic to. An ALB works with IP addresses, instance, and AWS Lambda target types. NLBs work with IPs and instances, and they can also route traffic to an ALB for more complex requests. GLBs work with IPs and instance target types.

Read about instances in cloud computing

Proxy behavior

The action that a load balancer takes when it receives a client request depends on one of two things:

  • If the load balancer acts as a proxy and then terminates the client’s connection
  • If it forwards the request without ending the flow

Terminating the flow enables load balancers to perform additional traffic management functions, such as SSL termination, session persistence, and content-based routing. 

An ALB terminates the client connection and then establishes a new connection, acting as a proxy. An NLB also terminates the client connection and makes a new one on behalf of the client. However, a GLB doesn’t act as a proxy or terminate the connection; it forwards traffic directly.

Protocols

These load balancers support different protocols to handle specific types of traffic and perform advanced functions. ALBs support HTTP, HTTPS, and gRPC protocols for web-based traffic. An NLB supports TCP, UDP, and TLS protocols, which covers network-level traffic distributions. Finally, a GLB covers IP-based routing, handling any IP-based protocols. 

Algorithms

These load balancers use different types of algorithms to distribute traffic evenly to their targets. An ALB uses a round-robin algorithm by default, routing traffic one after another. However, an NLB uses a flow hash algorithm so that traffic is routed to specific targets in a predetermined manner. A GLB uses routing table look-ups to determine where to route the traffic. 

When to use: ALB vs. NLB vs. GLB

An ALB is a good choice when you need flexible application-level traffic management and routing. It’s best with microservices, containerized environments, and web applications. Its features—such SSL termination, session persistence, and content-based routing—enable it to offer assistance with complex routing scenarios. 

An NLB is best for high-performance, low-latency, and scalable network-level balancing. Applications that distribute traffic on the transport layer use NLBs, especially considering its reliability. Gaming systems, media streaming services, and major IoT systems use NLBs. 

A GLB is ideal when you’re balancing on the network gateway level. For example, a GLB works well if you manage traffic between cloud and on-premises environments or across different regions. Because it combines OSI layers 3 and 4 balancing, it can route traffic between distinct regions and networks. Because it supports IP-based routing, it can distribute traffic across virtual gateways, so it can offer high scalability and availability.

Summary of differences: ALB vs. NLB vs. GLB

 

Application load balancer (ALB)

Network load balancer (NLB)

Gateway load balancer (GLB)

OSI layer

Works on layer 7, the application layer.

Works on layer 4, the transport layer.

Works on the network layer, layer 3, and layer 7.

Target types

Works with IP, instance, and lambda target types.

Works with IP, instance, and ALB target types.

Works with IP and instance target types.

Proxy behavior

Ends connection.

Ends connection.

Doesn’t terminate the flow.

Protocols

Supports HTTP, HTTPS, and gRPC protocols.

Supports TCP, UDP, and TLS protocols.

Supports IP-based routing. 

Algorithms

Round-robin.

Flow hash.

Routing table lookup.

How can AWS help with your load balancing requirements?

Elastic Load Balancing (ELB) is a fully managed load balancing service. It automatically distributes incoming application traffic to multiple targets and virtual appliances across Amazon Web Services (AWS) and on-premises resources. In addition, it supports cross-zone load balancing across AWS Regions. You can use ELB to set up ALB, NLB, or GLB according to your requirements. 

ALB is one component of ELB. ELB also supports NLB, GLB, and Classic Load Balancer. These load balancers are client contact points and help improve application scalability with secure management. You can choose one or multiple load balancers and configure them when you’re setting up ELB for your cloud environment.

Get started with load balancing on AWS by creating an account today.