What is a Network Load Balancer?

A Network Load Balancer (NLB) in AWS is designed to handle millions of requests per second while maintaining ultra-low latencies. It operates at the connection level (Layer 4) and is optimized to handle sudden and volatile traffic patterns. An NLB can distribute incoming traffic across multiple targets, such as Amazon EC2 instances, containers, and IP addresses, in one or more Availability Zones.

Different Types of Network Load Balancers

AWS offers several types of load balancers, each suited for different needs:

  1. Application Load Balancer (ALB): This load balancer operates at the application layer (Layer 7) and is best for HTTP/HTTPS traffic.
  2. Network Load Balancer (NLB): Operates at the transport layer (Layer 4) and is ideal for TCP/UDP traffic where extreme performance is required.
  3. Gateway Load Balancer (GWLB): Integrates with third-party virtual appliances and operates at Layer 3.

In this guide, we focus on the Network Load Balancer.

Creating a Network Load Balancer

To create an NLB, follow these steps:

  1. Sign in to the AWS Management Console.
  2. Navigate to the EC2 Dashboard.
  3. In the left navigation pane, choose Load Balancers under Load Balancing.
  4. Click on Create Load Balancer.
  5. Select Network Load Balancer.
  6. Configure the load balancer settings:
    • Name: Give your load balancer a unique name.
    • Scheme: Choose between Internet-facing or Internal.
    • IP address type: Choose between IPv4 or Dualstack.
  7. Configure the Listeners and routing. Add listeners (typically TCP) and define target groups.
  8. Choose the Availability Zones where your load balancer will route traffic.
  9. Review and create the load balancer.

Configuring a Network Load Balancer

After creating the NLB, you need to configure it:

  1. Target Groups: Define one or more target groups. These groups contain the targets (EC2 instances, IP addresses, etc.) that will receive traffic.
  2. Health Checks: Configure health checks to monitor the health of the targets. Ensure the health check settings match the application’s requirements.
  3. Listeners and Rules: Set up listeners to check for incoming connection requests. Define rules to route traffic based on specified conditions.

Routing Traffic to a Network Load Balancer

Routing traffic to an NLB involves:

  1. DNS Configuration: Associate a domain name with your NLB using Route 53 or another DNS provider.
  2. Listeners: Ensure listeners are correctly set up to accept incoming traffic on specified ports.
  3. Target Groups: Ensure target groups are correctly associated with the NLB and include healthy targets.

Using a Network Load Balancer with Auto Scaling

To leverage Auto Scaling with an NLB:

  1. Create an Auto Scaling group and attach it to the NLB target group.
  2. Configure scaling policies based on metrics like CPU utilization or network traffic.
  3. Monitor the Auto Scaling group to ensure instances are added and removed as needed based on traffic patterns.

Monitoring a Network Load Balancer

AWS provides several tools to monitor your NLB:

  1. CloudWatch Metrics: Monitor metrics such as request count, active flow count, and healthy host count.
  2. VPC Flow Logs: Capture detailed information about the IP traffic going to and from your NLB.
  3. AWS CloudTrail: Track API calls to your NLB for auditing and compliance.

Troubleshooting Network Load Balancers

Common troubleshooting steps include:

  1. Check Health Checks: Ensure that health checks are configured correctly and targets are healthy.
  2. Verify Listener Configurations: Ensure listeners are correctly configured to accept traffic on the expected ports.
  3. Review Logs: Use VPC Flow Logs and CloudWatch Logs to diagnose issues.
  4. Analyze Metrics: Use CloudWatch metrics to identify performance bottlenecks or unusual traffic patterns.

Conclusion

Creating and configuring a Network Load Balancer in AWS can significantly enhance the performance and reliability of your applications. By following the steps outlined in this guide, you can ensure optimal load balancing, efficient traffic routing, and robust monitoring and troubleshooting.

References

Create a Network Load Balancer

Target groups for your Network Load Balancers