What is a Network Load Balancer?
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.
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:
- 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.
- Listeners: Listeners monitor for incoming connection requests and route the request to a specific target based on the protocols and ports set up.
- 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.
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:
- Unlike a Classic Load Balancer, a Network Load Balancer is capable of handling millions of concurrent requests per second.
- The Network Load Balancer supports the assignment of static IP addresses.
- In a Network Load Balancer, the target can be registered using its IP address as well.
- 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
- Load Balancer serves over a million concurrent requests per second while providing extremely low latencies for applications that are sensitive to latency.
- The Network Load Balancer allows the back end to see the client's IP address by preserving the client-side source IP.
- Network Load Balancer also provides static IP support per subnet.
- In order to provide a fixed IP, Network Load Balancer also gives the option to assign an Elastic IP per subnet.
- Other AWS services such as Auto Scaling, Elastic Container Service (ECS), CloudFormation, Elastic BeanStalk, CloudWatch can be integrated with Network Load Balancer.
- 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
- Select Target Groups from the Load Balancing menu in the EC2 console.
- Select Create a target group.
- This takes us to the Specify group details page. Choose Instances as the target type.
- Enter a name for the new target group in the Target group name field.
- Choose protocol as TCP and port as 80.
- Choose any custom VPC or the default VPC for EC2 instances serving as targets and click Next.
- On the Register targets page, choose one or more targets in the Available instances section.
- Select Create a target group.
Step 2: Select the type of load balancer
- In the EC2 console, select Load Balancers.
- Click on Create a load balancer.
- Go to the Network Load Balancer option and click Create.
Step 3: Set up the listener and load balancer
- Enter the name of the load balancer under the Load balancer name.
- Keep the default values for Scheme and IP address type.
- Choose a VPC for the EC2 instances under Network mapping.
- Select the appropriate Availability Zones and subnets as needed, from the list under mappings.
- Keep the default protocol and port for listeners and routing.
- Then choose the target group that we created in Step 1, in the Default action list.
- Review and click on Create load balancer button.
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:
- New connections or flows: It defines the number of new connections or flows made each second.
- Active flows or connections: It defines the minutely sampled concurrent connections/flows.
- 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
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.
- 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.