Elastic Load Balancing helps distributing incoming traffic across multiple targets such as Amazon EC2 instances, microservices, and containers in one or more Availability Zones. It offers the following options –
- Application Load Balancer
- Network Load Balancer
- Classic Load Balancer
- Gateway Load Balancer
A Network Load Balancer is one of the different types of Elastic Load Balancing options offered by AWS.
It works at Layer 4 of the OSI Model – Transport Layer.
It offers a load balancing solution to distribute incoming TCP or UDP traffic across target groups. It can handle millions of requests per second.
For TCP traffic –
- an NLB selects a target using a flow hash algorithm based on the protocol, source IP address, source port, destination IP address, destination port, and TCP sequence number.
- Since the TCP connections from a client have different source ports and sequence numbers, they can be routed to different targets.
- Each individual TCP connection is routed to a single target for the life of the connection.
For UDP traffic –
- it selects a target using a flow hash algorithm based on the protocol, source IP address, source port, destination IP address, and destination port.
- Since UDP flow has the same source and destination, it is consistently routed to a single target throughout its lifetime.
You can register instance IDs, IP Addresses or an Application Load Balancer as target groups to a Network Load Balancer. They have the following features –
- If the target is an Instance ID, the source IP addresses of the clients are preserved and provided to the underlying applications.
- If the target is an IP Address, the source IP addresses are the private IP addresses of the load balancer nodes and the client IP is not passed down.
- If the target is an Application Load Balancer, the source IP addresses of the clients are preserved and provided.