Network Load Balancer (NLB)
The Network Load Balancer (NLB) is an AWS service designed to handle high-performance traffic at the Network Layer (Layer 4) of the OSI model. It efficiently distributes incoming TCP, UDP, and TLS traffic to targets, such as EC2 instances, containers, and on-premises servers, ensuring low latency and high throughput. NLB is particularly suitable for applications requiring ultra-low latency and high scalability.
Key Features of NLB:
Layer 4 Load Balancing:
- Operates at the transport layer, routing traffic based on IP addresses and ports without inspecting the application data.
Static IP or Elastic IPs:
- Provides a static IP address for the load balancer, or allows you to assign Elastic IPs for predictable and consistent endpoints.
TLS Termination:
- Offloads TLS/SSL decryption to the load balancer, reducing the computational load on backend servers.
Connection Stability:
- Supports long-lived TCP/UDP connections, making it suitable for real-time applications like gaming or streaming.
High Performance:
- Capable of handling millions of requests per second while maintaining ultra-low latency.
Health Checks:
- Performs health checks on targets to ensure traffic is routed only to healthy instances.
Cross-Zone Load Balancing:
- Distributes traffic evenly across multiple Availability Zones, enhancing availability.
IP Targeting:
- Directly routes traffic to IP addresses, allowing you to balance traffic to targets outside AWS (e.g., on-premises servers).
Use Cases:
Real-Time Applications:
- Ideal for gaming, streaming, and real-time communication platforms due to low latency.
High-Performance Applications:
- Suitable for applications requiring high throughput, such as data ingestion and analytics.
Hybrid Architectures:
- Balances traffic between on-premises servers and AWS resources.
IoT Applications:
- Supports massive connections from IoT devices due to its ability to handle millions of requests per second.
TCP and UDP Workloads:
- Manages workloads using protocols like TCP, UDP, and TLS without deep packet inspection.
How It Works:
Traffic Handling:
Incoming traffic is routed to the load balancer's static IP or Elastic IP.
The NLB evaluates the listener rules to determine the appropriate target group.
Target Groups:
Targets (EC2 instances, containers, IP addresses, etc.) are organized into target groups.
NLB routes traffic to the target group based on the listener configuration.
Health Checks:
NLB periodically checks the health of targets using TCP or HTTP/HTTPS probes.
Unhealthy targets are automatically excluded from the routing pool.
Connection Distribution:
- NLB maintains long-lived connections for high-performance traffic distribution.
Workflow:
Client Request:
- A client sends a TCP or UDP request to the NLB's static IP or DNS name.
Routing:
- The NLB routes the request to the appropriate target in a target group based on listener rules.
Backend Processing:
- The target processes the request and sends the response back to the NLB.
Response Delivery:
- The NLB forwards the response to the client.
Summary:
Network Load Balancer (NLB)
Layer: Operates at Layer 4 (Transport Layer).
Purpose: High-performance traffic routing for TCP, UDP, and TLS.
Features:
Handles millions of requests per second with ultra-low latency.
Provides static IPs or Elastic IPs.
Supports TLS termination.
Use Cases:
Real-time applications (e.g., gaming, IoT).
High-performance backend systems.