3-Tier Architecture (Part -7)

External Load Balancer and Auto Scaling Table of Contents Web Tier AMI Target Group Internet Facing Load Balancer Launch Template Auto Scaling Conclusion Web Tier AMI Navigate to Instances on the left-hand side of the EC2 dashboard. Select the web tier instance we created and under Actions, select Image and templates. Click Create Image. Provide a name and description for the image and then click Create image. To monitor the status of the image creation, navigate to AMIs under Images on the left-hand panel of the EC2 dashboard. Target Group While the AMI is being created, let's set up our target group for the load balancer: Navigate to Target Groups under Load Balancing in the EC2 dashboard. Click Create Target Group. Select Instances as the target type and provide a name. Set the protocol to HTTP and port to 80 (as NGINX listens on this port). Choose the VPC we've been using. Change the health check path to /health. Click Next. Skip registering targets for now and create the target group. Internet Facing Load Balancer Navigate to Load Balancers under Load Balancing in the EC2 dashboard. Click Create Load Balancer. Select Application Load Balancer. Provide a name and select Internet Facing. Choose the correct network configuration for VPC and public subnets. Select the security group created for this ALB. Ensure that the ALB listens for HTTP traffic on port 80. Set it to forward traffic to the target group created earlier. Click Create Load Balancer. Launch Template Before configuring Auto Scaling, create a Launch Template: Navigate to Launch Templates under Instances in the EC2 dashboard. Click Create Launch Template. Provide a name for the template. Under Application and OS Images, select the AMI created earlier. Choose t2.micro as the instance type. Skip Key pair and Network Settings (we’ll configure these in Auto Scaling). Select the correct security group for the web tier. Under Advanced details, use the same IAM instance profile used for our EC2 instances. Click Create Launch Template. Auto Scaling Now, we create the Auto Scaling Group: Navigate to Auto Scaling Groups under Auto Scaling in the EC2 dashboard. Click Create Auto Scaling Group. Provide a name for the Auto Scaling group. Select the Launch Template created earlier and click Next. Choose the VPC and public subnets for the web tier. Attach the Auto Scaling Group to the Load Balancer by selecting the existing web tier load balancer’s target group. Click Next. Set desired, minimum, and maximum capacity to 2. Click Skip to review, then Create Auto Scaling Group. After the above step, click Next, Next, and finally, Create Auto Scaling Group. Now, our WebApp is successfully set up!

Mar 31, 2025 - 09:56
 0
3-Tier Architecture (Part -7)

External Load Balancer and Auto Scaling

Table of Contents

  1. Web Tier AMI
  2. Target Group
  3. Internet Facing Load Balancer
  4. Launch Template
  5. Auto Scaling
  6. Conclusion

Web Tier AMI

  1. Navigate to Instances on the left-hand side of the EC2 dashboard.
  2. Select the web tier instance we created and under Actions, select Image and templates.
  3. Click Create Image.
  4. Provide a name and description for the image and then click Create image.
  5. To monitor the status of the image creation, navigate to AMIs under Images on the left-hand panel of the EC2 dashboard.

Target Group

While the AMI is being created, let's set up our target group for the load balancer:

  1. Navigate to Target Groups under Load Balancing in the EC2 dashboard.
  2. Click Create Target Group.
  3. Select Instances as the target type and provide a name.
  4. Set the protocol to HTTP and port to 80 (as NGINX listens on this port).
  5. Choose the VPC we've been using.
  6. Change the health check path to /health.
  7. Click Next.
  8. Skip registering targets for now and create the target group.

Internet Facing Load Balancer

  1. Navigate to Load Balancers under Load Balancing in the EC2 dashboard.
  2. Click Create Load Balancer.
  3. Select Application Load Balancer.
  4. Provide a name and select Internet Facing.
  5. Choose the correct network configuration for VPC and public subnets.
  6. Select the security group created for this ALB.
  7. Ensure that the ALB listens for HTTP traffic on port 80.
  8. Set it to forward traffic to the target group created earlier.
  9. Click Create Load Balancer.

Launch Template

Before configuring Auto Scaling, create a Launch Template:

  1. Navigate to Launch Templates under Instances in the EC2 dashboard.
  2. Click Create Launch Template.
  3. Provide a name for the template.
  4. Under Application and OS Images, select the AMI created earlier.
  5. Choose t2.micro as the instance type.
  6. Skip Key pair and Network Settings (we’ll configure these in Auto Scaling).
  7. Select the correct security group for the web tier.
  8. Under Advanced details, use the same IAM instance profile used for our EC2 instances.
  9. Click Create Launch Template.

Auto Scaling

Now, we create the Auto Scaling Group:

  1. Navigate to Auto Scaling Groups under Auto Scaling in the EC2 dashboard.
  2. Click Create Auto Scaling Group.
  3. Provide a name for the Auto Scaling group.
  4. Select the Launch Template created earlier and click Next.
  5. Choose the VPC and public subnets for the web tier.
  6. Attach the Auto Scaling Group to the Load Balancer by selecting the existing web tier load balancer’s target group.
  7. Click Next.
  8. Set desired, minimum, and maximum capacity to 2.
  9. Click Skip to review, then Create Auto Scaling Group.
  10. After the above step, click Next, Next, and finally, Create Auto Scaling Group.

Now, our WebApp is successfully set up!