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:

  1. Layer 4 Load Balancing:

    • Operates at the transport layer, routing traffic based on IP addresses and ports without inspecting the application data.
  2. 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.
  3. TLS Termination:

    • Offloads TLS/SSL decryption to the load balancer, reducing the computational load on backend servers.
  4. Connection Stability:

    • Supports long-lived TCP/UDP connections, making it suitable for real-time applications like gaming or streaming.
  5. High Performance:

    • Capable of handling millions of requests per second while maintaining ultra-low latency.
  6. Health Checks:

    • Performs health checks on targets to ensure traffic is routed only to healthy instances.
  7. Cross-Zone Load Balancing:

    • Distributes traffic evenly across multiple Availability Zones, enhancing availability.
  8. IP Targeting:

    • Directly routes traffic to IP addresses, allowing you to balance traffic to targets outside AWS (e.g., on-premises servers).

Use Cases:

  1. Real-Time Applications:

    • Ideal for gaming, streaming, and real-time communication platforms due to low latency.
  2. High-Performance Applications:

    • Suitable for applications requiring high throughput, such as data ingestion and analytics.
  3. Hybrid Architectures:

    • Balances traffic between on-premises servers and AWS resources.
  4. IoT Applications:

    • Supports massive connections from IoT devices due to its ability to handle millions of requests per second.
  5. TCP and UDP Workloads:

    • Manages workloads using protocols like TCP, UDP, and TLS without deep packet inspection.

How It Works:

  1. 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.

  2. 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.

  3. Health Checks:

    • NLB periodically checks the health of targets using TCP or HTTP/HTTPS probes.

    • Unhealthy targets are automatically excluded from the routing pool.

  4. Connection Distribution:

    • NLB maintains long-lived connections for high-performance traffic distribution.

Workflow:

  1. Client Request:

    • A client sends a TCP or UDP request to the NLB's static IP or DNS name.
  2. Routing:

    • The NLB routes the request to the appropriate target in a target group based on listener rules.
  3. Backend Processing:

    • The target processes the request and sends the response back to the NLB.
  4. 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.