What is a Network Load Balancer?

Learn via video courses

Overview

To guarantee a positive user experience and low latency, it becomes essential for client applications to handle massive traffic reliably. The incoming load must be distributed among multiple computing resources in order to handle millions of concurrent incoming requests on an application; this type of computing is known as load balancing. AWS provides a very effective managed load balancer called Network Load Balancer as part of its Elastic Load Balancing service, which has the potential to handle millions of concurrent requests per second while working upon the Transport Layer (Layer 4) of the OSI model.

What is a Network Load Balancer?

A Network Load Balancer operates on the Transport Layer (Layer 4) of the Open Systems Interconnection (OSI) model rather than the application layer, making it ideal for Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) traffic. It is suitable for applications anticipating an unexpected spike in traffic because it can handle millions of concurrent requests per second. A network load balancer is the best option in such situations to manage and distribute the traffic, for example, in the case of a gaming application that anticipates a sudden increase in the number of incoming users during a particular gaming championship.

illustration of network load balancer

Additionally, a Network Load Balancer cannot be used with applications serving HTTP or HTTPS because it operates at Layer 4 (Transport Layer). This also restricts the ability of the Network Load Balancer to offer features like headers and cookies.

Network Load Balancer Components

The components listed below make up a network load balancer:

  1. Load Balancer: A load balancer serves as the entry point for client requests, which are then directed to the appropriate target, such as EC2 instances, based on the configuration.
  2. Listeners: Listeners monitor for incoming connection requests and route the request to a specific target based on the protocols and ports set up.
  3. Target Groups: A target, such as an EC2 instance, is registered within a target group that responds to the incoming connection request. To effectively load balance, a target group may have multiple targets registered.

component-of-network-load-balancer

Benefits of Migrating from a Classic Load Balancer

Classic Load Balancer works on the Transport and Application Layers (Layers 4 and 7). Being one of the first load balancers, Classic Load Balancer will shortly be retired by AWS. It is therefore recommended to utilize either an Application load balancer or a Network load balancer, depending on the requirements.

The advantages of employing a Network Load Balancer over a Classic Load Balancer include:

  1. Unlike a Classic Load Balancer, a Network Load Balancer is capable of handling millions of concurrent requests per second.
  2. The Network Load Balancer supports the assignment of static IP addresses.
  3. In a Network Load Balancer, the target can be registered using its IP address as well.
  4. Requests can be routed to multiple applications running on a single EC2 instance using a Network Load Balancer, which is not possible with a Classic Load Balancer.

Features of Network Load Balancer

  1. Load Balancer serves over a million concurrent requests per second while providing extremely low latencies for applications that are sensitive to latency.
  2. The Network Load Balancer allows the back end to see the client's IP address by preserving the client-side source IP.
  3. Network Load Balancer also provides static IP support per subnet.
  4. In order to provide a fixed IP, Network Load Balancer also gives the option to assign an Elastic IP per subnet.
  5. Other AWS services such as Auto Scaling, Elastic Container Service (ECS), CloudFormation, Elastic BeanStalk, CloudWatch can be integrated with Network Load Balancer.
  6. To communicate with other VPCs, network load balancers can be used with PrivateLink. AWS PrivateLink offers secure and private access between on-premises networks, AWS services, and VPCs.

How to Create a Network Load Balancer?

To create a network load balancer, follow the below-mentioned steps:

Step 1: Configure your target group

  1. Select Target Groups from the Load Balancing menu in the EC2 console. select target groups in ec2 console
  2. Select Create a target group.
  3. This takes us to the Specify group details page. Choose Instances as the target type.
  4. Enter a name for the new target group in the Target group name field.
  5. Choose protocol as TCP and port as 80.
  6. Choose any custom VPC or the default VPC for EC2 instances serving as targets and click Next. custom vpc for ec2 instances as targets
  7. On the Register targets page, choose one or more targets in the Available instances section.
  8. Select Create a target group.

Step 2: Select the type of load balancer

  1. In the EC2 console, select Load Balancers.
  2. Click on Create a load balancer. select type load balancer
  3. Go to the Network Load Balancer option and click Create.

Step 3: Set up the listener and load balancer

  1. Enter the name of the load balancer under the Load balancer name.
  2. Keep the default values for Scheme and IP address type.
  3. Choose a VPC for the EC2 instances under Network mapping.
  4. Select the appropriate Availability Zones and subnets as needed, from the list under mappings.
  5. Keep the default protocol and port for listeners and routing.
  6. Then choose the target group that we created in Step 1, in the Default action list.
  7. Review and click on Create load balancer button.

set up listener and load balancer

Network Load Balancer Pricing

The number of Network Load Balancer Capacity Units (NLCU) used by a Network Load Balancer per hour and the number of full or partial hours that a Network Load Balancer is running are the two metrics that are used to calculate the Network Load Balancer bill. Each AWS region has a different price for these metrics.

The Network Load Balancer's processing of traffic is measured by an NLCU. The three parameters that affect the pricing of an NLCU are as follows:

  1. New connections or flows: It defines the number of new connections or flows made each second.
  2. Active flows or connections: It defines the minutely sampled concurrent connections/flows.
  3. Bytes processed: The amount of data that the load balancer processed is measured in GBs.

Only one of the above three dimensions with the highest hourly usage is billed.

Classic Load Balancer vs Application Load Balancer vs Network Load Balancer

types of load balancers

Classic Load Balancer:

The HTTP, HTTPS (Secure HTTP), SSL (Secure TCP), and TCP protocols are all supported for load balancing by the Classic Load Balancer. It operates on Layers 4 and Layers 7 of the OSI model. One of the first load balancers, the Classic Load Balancer, is soon to be retired by AWS. Therefore, depending on the situation, it is advised to use either an Application load balancer or a Network load balancer.

Application Load Balancer:

Applications running on HTTP and HTTPS (Secure HTTP) are supported by an application load balancer. Since it operates at Layer 7, it supports headers, cookies, sticky sessions, HTTP, and HTTPS. For SSL certificates, it also supports integration with AWS Certificate Manager (ACM).

Network Load Balancer: Both TCP and UDP connection load balancing are offered by Network Load Balancer. It offers extremely low latencies and is designed to handle millions of requests per second and unpredictable traffic patterns. The Network Load Balancer also offers stable IP support, zonal isolation, and TLS termination support. It does not support HTTP, HTTPS, cookies, headers, or other application layer features because it operates at Layer 4.

Conclusion

  • A Network Load Balancer is ideal for Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) traffic.
  • It is suitable for applications anticipating an unexpected spike in traffic. Millions of concurrent requests per second can be handled by a network load balancer.
  • Components of a Network Load Balancer include Load Balancer, Listeners, and Target Groups.
  • AWS Network Load Balancing Service is designed to provide extremely low latencies for applications that are sensitive to latency.
  • Other AWS services such as Auto Scaling, Elastic Container Service (ECS), CloudFormation, Elastic BeanStalk, and CloudWatch can be easily integrated with Network Load Balancer.
  • The two metrics that are utilized to compute the network load balancer bills are the number of network load balancer capacity units (NLCU) consumed by a network load balancer per hour and the number of full or partial hours that a network load balancer is running.
  • Various load balancer types, including Classic Load Balancer, Application Load Balancer, and Network Load Balancer, are available through AWS.