- A Cloud Guru
Creating and Configuring a Network Load Balancer in AWS
In this hands-on lab, 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.
Table of Contents
Create and Configure a Subnet
From the VPC Console, create a new public Subnet called Public B. This subnet should use the us-east-1b availability zone with a CIDR block of 10.0.2.0/24. Once the subnet has been created, add a route to the Internet Gateway that was deployed with the lab and configure the explicit subnet association to use the new Public B subnet.
Edit the Network ACL
For the newly created Public B subnet, modify the Network ACL to only permit traffic from anywhere on ports:
- HTTP (80)
- HTTPS (443)
- SSH (22)
- Ephemeral Ports (1024 - 65535)
Create EC2 Instances
Create an EC2 instance called WebA. The EC2 instance should use the latest Amazon Linux AMI and be of type t3.micro. Configure the network settings for the instance to use the PublicA subnet, auto-assign public IP, and for the security group, select the preconfigured EC2 Security group. Additionally, deploy the instance with the WebA user data script.
Repeat the same steps to deploy a second EC2 instance with the same settings but this time configuring the instance in the PublicB subnet and deployed with the WebB user data script.
Create and Configure a Network Load Balancer
Deploy a Network Load Balancer that is Internet Facing over IPv4. Include both us-east-1a and us-east-1b in the network mappings. Create a Target Group using instances with a protocol of TCP over port 80. Configure the Health Check to monitor TCP. For the targets, include WebA and WebB. Once the Target Group is created, continue with the Network Load Balancer configuration and apply the new target group.
Test and Monitor the Network Load Balancer
Once the Load Balancer has been provisioned, located the Load Balancer DNS name and in a new browser tab, navigate to the URL. Observe that the page is served by either WebA or WebB.
Next, log into the AdminInstance and generate some traffic to the instances with the following command:
while true; do curl <LOAD BALANCE DNS NAME>; done
Allow this to run for a few minutes and then break out of the command using CTRL+C.
On the Load Balancer page, view the Monitoring tab and observe the results of the simulated traffic.
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.