AWS

An overview of different types of load balancers on AWS

As the name suggests, a load balancer is a server that accepts multiple connection requests from multiple sources and distributes them equally among multiple targets in different availability zones. It is some kind of a single point of interaction for the end-users to hit the target servers.

There are different types of load balancers for different purposes available on AWS. Following is the list of all the available load balancers on AWS.

  • Gateway load balancer
  • Network load balancer
  • Application load balancer
  • Classic load balancer

In this guide, we will discuss all these types of load balancers and explain the major differences between all these load balancers are.

Gateway load balancer

Gateway load balancer is the type of elastic load balancer provided by AWS and can be used to deploy, manage and scale virtual appliances like IDS, IPS and firewalls. It is the latest type of load balancer and operates at the 3rd layer of the OSI (open system interconnection) layer model and listens for all IP packets on all ports of the load balancer, then forwards the traffic to a specific target group configured in the listener rule.

Gateway load balancer can be used to exchange traffic securely across VPCs by using the gateway load balance endpoints. Gateway load balancer endpoint is a VPC endpoint that is used for private connectivity between the virtual appliance and application server in different VPCs.

Route table is used to configure the traffic to and from a gateway load balancer. The network traffic from application servers in one VPC goes to the gateway load balancer over the gateway load balancer endpoint in another VPC and then returns to the previous VPC. The gateway load balancer endpoint and application servers must be created in different subsets of the VPC.

Network load balancer

Network load balancer is the current generation load balancer provided by AWS. It operates at the 4th layer of the OSI (open system interconnection) layer model and can respond to millions of requests per second. After receiving the request from the end-user, the network load balancer routes that request to a target in the target group. It opens a TCP connection to the selected target on a port specified in the target group configuration.

Network load balancer can send requests to multiple targets in different availability zones. While creating the load balancer, will ask for the availability zones in which you want to deploy the load balancer. The elastic load balancer then creates nodes in all the selected availability zones. The network load balancer distributes the traffic to its own availability zone only. Still, if you have enabled the cross zone load balancing feature, it will distribute the load across different availability zones.

Following is a list of benefits of using a network load balancer.

  • Targets for the network load balancer can be registered by IP, so the targets outside the VPC of the load balancer can be configured to receive traffic from the network load balancer.
  • It can handle the volatile load and can scale up to millions of requests per second.
  • A static IP can be assigned to the network load balancer.
  • You can send requests to a single instance running multiple applications. A single instance can be made part of different target groups with different ports.

Application load balancer

Application load balancer is an elastic load balancer that runs on the application layer (layer 7 of the OSI layer model) and receives only HTTP and HTTPS connection requests. It acts as a single point of entry for the incoming requests and distributes the traffic among targets in a target group.

Besides balancing the load among multiple targets, the main function of the application load balancer is to route traffic using some listener rules. These listener rules make the application load balancer an intelligent load balancer. Listener rules in an application load balancer listener can be added based on the following parameters.

  • Host header: incoming traffic can be routed to different target groups based on the host header.
  • Path: requests with different request paths can also be routed to different target groups by adding a listener rule.
  • Http header: Application load balancer listener can be configured to route traffic to different target groups by checking the Http request header.
  • Http request method: Incoming http requests with different http request methods like POST, GET, DELETE and update can also be routed to different target groups.
  • Query string: requests on the application load balancer can be sent to different target groups based on the query string.
  • Source IP: requests from different geographical regions can be sent to different target groups by checking the source IP.

Classic load balancer

Classic load balancer is a previous generation load balancer and provides basic load balancing across multiple instances. This load balancer operates at both the 7th and 4th layers. It is useful for the applications that are deployed in the EC2 classic network.

AWS recommends using the application load balancer for 7th layer traffic and network load balancer for 4th layer traffic in the VPC (virtual private cloud).

Conclusion

AWS ELB (elastic load balancer) provides different types of load balancers for different use cases. There are a total of 4 types of load balancers provided by AWS. The application load balancer, network load balancer and gateway load balancer are current generations load balancers, and AWS recommends using them. Classic load balancer is a previous generation load balancer and is useful for EC2 classic networks. This guide gives a basic understanding of the different load balancers provided by AWS.

About the author

Zain Abideen

A DevOps Engineer with expertise in provisioning and managing servers on AWS and Software delivery lifecycle (SDLC) automation. I'm from Gujranwala, Pakistan and currently working as a DevOps engineer.