Definition – Network Load Balancer
A Network Load Balancer (NLB) operates at the transport layer (Layer 4) of the OSI model and is designed to handle very high-performance networking traffic by distributing TCP/UDP traffic across multiple servers. Unlike Application Load Balancers which route traffic based on application-level information like HTTP headers, Network Load Balancers focus on IP protocol data, such as source and destination IP addresses and ports. Inother word, Network Load Balancers route traffic based on TCP or UDP data, without inspecting packet content.

Key Features of Network Load Balancers
- High Performance and Low Latency: NLBs are optimized for handling millions of requests per second with very low latencies, suitable for real-time and high-throughput applications.
- Connection-Based Routing: They route traffic based on TCP or UDP connections, maintaining the connection state, which is essential for protocols requiring sustained connections.
- IP Address as a Target: NLBs can route requests directly to primary IPs of the target instances, rather than depending on a translation or mapping, reducing overhead and complexity.
- Elasticity and Scalability: Automatically adjusts to handle fluctuations in traffic, seamlessly handling increases in load without any manual intervention.
- Health Checks: Regularly perform health checks on the servers to ensure traffic is only routed to healthy servers, enhancing the fault tolerance of applications.
- Static IP Support: For each Availability Zone where it routes traffic, it can support assigning one static IP per NLB, which is particularly useful for whitelisting specific IP addresses in firewall rules.
How It Works
A Network Load Balancer listens for incoming client connections, selecting a target from a group based on the chosen load balancing algorithm. Once it establishes a connection to a target for a particular client, it routes traffic from that client to the same target consistently, using the TCP connection parameters. This approach, known as connection stickiness, is critical for applications that require the maintenance of individual session states.
Example Scenario
Consider a large gaming company that has multiplayer games requiring real-time, low-latency connections between the players’ devices and the game servers. The company deploys a Network Load Balancer to manage the heavy UDP traffic generated by thousands of players connected simultaneously.
Setup:
- Servers: Multiple game servers are set up across various data centers to handle and process game state information.
- Network Load Balancer: Positioned at the entry point to distribute incoming game traffic across these servers.
Operation:
- As players connect to the game, the NLB receives their connections and distributes them across the available game servers based on factors like the number of active connections and server health.
- Once a player’s connection is directed to a specific server, all subsequent data for that session is routed to the same server, ensuring consistent and low-latency game state updates.
This setup allows the gaming company to efficiently manage thousands of concurrent connections, maintain a high level of performance, and ensure a smooth gaming experience for all players.
Summary
A Network Load Balancer (NLB) operates at the transport layer (Layer 4) to manage high volumes of TCP/UDP traffic, focusing on low latency and high throughput. It distributes traffic across multiple servers using a flow hash routing algorithm based on IP address and port, ensuring effective load distribution, and maintaining client session affinity. NLBs are particularly beneficial for applications requiring real-time response and high availability, such as online multiplayer games, where they help ensure a seamless and stable user experience by balancing the load and conducting continuous health checks on servers.
Useful Links
https://sanchitgurukul.com/proxy
https://sanchitgurukul.com/load-balancer
