Creating and configuring a network load balancer in AWS

Lab Details

  1. This lab walks you through the steps to create and configure a network load balancer.

  2. Duration: 1 hour.

  3. AWS Region: US East (N. Virginia) us-east-1


Elastic Load Balancer (ELB)

  1. Elastic Load Balancing is one of the services provided by AWS to distribute the incoming application or network traffic across multiple targets, such as EC2 instances, containers, and IP addresses.

  2. ELB scales your load balancer based on traffic over time.

  3. ELB makes your applications highly available and fault tolerant.     

  4. It uses health checks to detect which instances are healthy and directs traffic only across those instances.

  5. You can add and remove resources from your load balancer depending on your need without disrupting the flow of requests to your applications.

Types of Elastic Load Balancers

  1. Elastic Load Balancing supports three types of load balancers:

  • Application Load Balancer

  • Network Load Balancer

  • Classic Load Balancer

    • Application Load Balancer is best suited for load balancing of HTTP and HTTPS traffic

    • Network Load Balancer is used to distribute the traffic or load using TCP/UDP protocols

    • Classic Load Balancer provides basic load balancing across multiple Amazon EC2 instances. 

Network Load Balancer

  1. The network load balancer (NLB) distributes the traffic based on network variables, such as IP address and destination ports.

  2. NLB is capable of processing traffic and scaling at a much higher rate than the application load balancer.

  3. We can't use some features of the Application Load Balancer such as SSL-offloading, host-based routing, cross-zone load balancing, and a few others.

  4. The complete comparison among load balancers can be found in the link Load balancer differences.

  5. It is not designed to take into consideration anything at the application layer, such as content type, cookie data, custom headers, user location, or the application behavior.

  6. For TCP traffic, NLB selects a target using a flow hash algorithm based on the type of protocol, source IP address, source port, destination IP address and destination port.

  7. TCP connections from a client have different source ports and sequence numbers compared with NLB and can be routed to different targets. 

  8. Each individual TCP connection is routed to a single target for a connection.

  9. A UDP flow has the same source and destination, so it is consistently routed to a single target throughout its lifetime. 

  10. Different UDP flows have different source IP addresses and ports, so they can be routed to different targets. 

  11. The advantage of NLB is that it can manage the traffic to a different port to the same instance.

  12. We can split the request based on the port to different services using the Network Load Balancer, thus NLB allows you to route the traffic among multiple applications running on the same server.

Architecture Diagram

Task Details

  1. Launching Lab Environment

  2. Creating an EC2 instance 

  3. Creating a Network Load balancer with two target groups named apache-tg and nginx-tg.

  4. Route traffic to port 80.

  5. Attach the instance with nginx-tg to listen to the Nginx service on port 8080.

  6. Installing Apache and Nginx services in the EC2 instance.

  7. Testing the Network Load Balancer.

  8. Validation of the lab.

  9. Deleting AWS Resources.