AWS Elastic Load Balancing (ELB) service supports three types of load balancers:
- Application Load Balancer,
- Network Load Balancer, and
- Classic Load Balancer.
As the name suggests, the Application Load Balancer works at the application layer and understands protocols such as HTTP. This gives the load balancer the ability to support routing rules based on the URL or the host field in the HTTP header, for example.
Create a new VPC with the Name tag lab-005 and the IPv4 CIDR block 192.168.0.0/16. Then create two public subnets in distinct availability zones of your VPC. Make sure to set the CIDR IPv4 block correctly to each subnet according to the ranges specified in the architecture diagram. You can use tags subnet-A and subnet-B for the subnets.
Create an Internet gateway with the Name tag lab-005 and attach it to lab-005 VPC. This procedure is described in detail in step 2 of lab-002.
Add a default route on your VPC router with a destination to the Internet gateway created in the previous step. Go to Subnet Associations and associate both subnets to the Main Route Table.
Launch an EC2 instance on each of the public subnets you created in the first step of this lab.
- You can use Amazon Linux 2 AMI.
- You can choose the Free tier eligible instance type.
- Make sure to set the correct VPC and subnet for each instance; also, use the provided user-data to setup an HTTP server on your instances.
- You can select the suggested storage for your instances.
- You should add a Name tag to help identifying your instances.
- Both instances should be in a Security Group with inbound rules that accept SSH and HTTP traffic.
- You should secure your instances by creating a lab-005 key pair.
At this point you should be able to access both instances using a browser an the instances public IP addresses. You should be able to see the hostname of each instance as the index page.
Follow the procedure described by the screenshots.
Copy the DNS name associated with the load balancer and, using a browser, try to access it. You should be able to see alternate responses (as you refresh the page) of the two instances webpages which proves that the load balancer is working properly by redirecting the request evenly to the two instances.
Another test you should do is to stop one of the instances and verify that the load balancer will not send requests to the stopped instance anymore.
No comments:
Post a Comment