- Lab
- A Cloud Guru

Creating and Configuring a Network Load Balancer in AWS
In the learning activity, the student will use what they have learned about Network Load Balancers to deploy and configure a simple web application with traffic load balanced between two web servers. The student will walk through preparing the AWS environment for the Network Load Balancer (configuring subnets, network ACL, and EC2 instances). When the preparation is complete, the student will create and configure a Network Load Balancer. After configuration of the load balancer, the student will work from the CLI to run a small test on the load balancer and view the results in the CloudWatch *Monitoring* metrics.

Path Info
Table of Contents
-
Challenge
Create and Configure a Subnet
- From the AWS Management Console, navigate to the VPC Management Console.
- Select Subnets.
- You will see one subnet already created. To create a second subnet, click Create subnet.
- Select the VPC provided.
- Name the subnet Public B.
- Select the us-east-1b Availability Zone.
- Enter a CIDR block which will not overlap with the CIDR block of the existing subnet.
- Create the Public B subnet.
- Navigate to the route table for the new Public B subnet.
- Update the routes on the route table to have a route for 0.0.0.0/0 pointing to the internet gateway of the VPC.
- Update the explicit subnet associations to use the new Public B subnet.
-
Challenge
Edit the Network ACL
- Select Subnets.
- Select the Public B subnet.
- Under the Network ACL tab, click on the network ACL link.
- Edit the inbound rules to permit only ports 80, 443, 22, and 1024 through 65535.
- Click Save changes.
-
Challenge
Create EC2 Instances
-
Navigate to the EC2 Management Console.
-
Click on Instances.
-
Click on Launch instances.
-
Configure a new instance called Web-A with the following values:
- AMI: Amazon Linux 2
- Instance Type: t2.micro
- Subnet: us-east-1a
- Auto-assign Public IP: Enable
- User data: use the Web-A script provided with the lab
- Volume Size: 8 GB
- Security Group: use the provided security group (not the default security group)
-
Configure a new instance called Web-B with the following values:
- AMI: Amazon Linux 2
- Instance Type: t2.micro
- Subnet: us-east-1b
- Auto-assign Public IP: Enable
- User data: use the Web-B script provided with the lab
- Volume Size: 8 GB
- Security Group: use the provided security group (not the default security group)
-
-
Challenge
Create and Configure a Network Load Balancer
-
Click on Load Balancers
-
Click Create Load Balancer
-
Select the Network Load Balancer option and, in the Basic Configuration section, set the following values:
- Load Balancer name: NLB4LAB
- Scheme: internet-facing
-
In the Network mapping section, use the provided VPC and select both us-east-1a and us-east-1b
-
In the Listeners and routing section, click Create target group
-
Use the following values for the new target group:
- Choose a target type: instances
- Target group name: nlbTargets
- Protocol: TCP
- Port: 80
- Health check protocol: TCP
-
Register both the Web-A and Web-B instances to the nlbTargets target group
-
Back on the Create Network Load Balancer page, in the Listeners and Routing section, select the nlbTargets target group
-
Click Create Load Balancer
-
-
Challenge
Test and Monitor the Network Load Balancer
- Click Load Balancers and select the NLB4LAB load balancer
- From the Description tab, copy the DNS name of the load balancer and view the web page in a new browser tab
- In a second tab, navigate to the EC2 console and click on Instances
- Select the AdminInstance server and, from the Details tab, copy the public IP address
- In the terminal of your choice, SSH into the AdminInstance server
- Run the following command from the AdminInstance server:
while true; do curl <LOAD BALANCER DNS NAME>; done
- Let the command run for multiple iterations and then hit Ctrl+C to break out of the loop
- Back on the Load Balancers page, click the Monitoring tab and review the CloudWatch metrics for network activity
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.

