AWS Three-Tier Architecture: Part-5

Internal Load Balancing and Auto Scaling

App Tier AMI

  1. Navigate to Instances on the left hand side of the EC2 dashboard. Select the app tier instance we created and under Actions select Image and templates. Click Create Image.

  2. Give the image a name and description and then click Create image. This will take a few minutes, but if you want to monitor the status of image creation you can see it by clicking AMIs under Images on the left hand navigation panel of the EC2 dashboard.

Target Group

  1. While the AMI is being created, we can go ahead and create our target group to use with the load balancer. On the EC2 dashboard navigate to Target Groups under Load Balancing on the left hand side. Click on Create Target Group.

  2. The purpose of forming this target group is to use with our load blancer so it may balance traffic across our private app tier instances. Select Instances as the target type and give it a name.

    Then, set the protocol to HTTP and the port to 4000. Remember that this is the port our Node.ja app is running on. Select the VPC we've been using thus far, and then change the health check path to be /health. This is the health check endpoint of our app. Click Next.

  3. We are NOT going to register any targets for now, so just skip that step and create the target group.

Internal Load Balancer

  1. On the left hand side of the EC2 dashboard select Load Balancers under Load Balancing and click Create Load Balancer.

  2. We'll be using an Application Load Balancer for our HTTP traffic so click the create button for that option.

  3. After giving the load balancer a name, be sure to select internal since this one will not be public facing, but rather it will route traffic from our web tier to the app tier.

    Select the correct network configuration for VPC and private subnets.

    Select the security group we created for this internal ALB. Now, this ALB will be listening for HTTP traffic on port 80. It will be forwarding the traffic to our target group that we just created, so select it from the dropdown, and create the load balancer.

Launch Template

  1. Before we configure Auto Scaling, we need to create a Launch template with the AMI we created earlier. On the left side of the EC2 dashboard navigate to Launch Template under Instances and click Create Launch Template.

  2. Name the Launch Template, and then under Application and OS Images include the app tier AMI you created.

    Under Instance Type select t2.micro. For Key pair and Network Settings don't include it in the template. We don't need a key pair to access our instances and we'll be setting the network information in the autoscaling group.

  3. Set the correct security group for our app tier, and then under Advanced details use the same IAM instance profile we have been using for our EC2 instances.

Auto Scaling

  1. We will now create the Auto Scaling Group for our app instances. On the left side of the EC2 dashboard navigate to Auto Scaling Groups under Auto Scaling and click Create Auto Scaling group.

  2. Give your Auto Scaling group a name, and then select the Launch Template we just created and click next.

  3. On the Choose instance launch options page set your VPC, and the private instance subnets for the app tier.

  4. For this next step, attach this Auto Scaling Group to the Load Balancer we just created by selecting the existing load balancer's target group from the dropdown. Then, click next.

  5. For Configure group size and scaling policies, set desired, minimum and maximum capacity to 2. Click skip to review and then Create Auto Scaling Group.

  6. After the above step Click next, next finally click "create autoscaling group"

Conclusion

I hope you found this journey through AWS three-tier architecture implementation insightful and enjoyable.

Please continue to Part 6 to learn more about the further steps in our implementation process.

You can access Part 6 via the following link below:

AWS Three Tier Architecture(Part-6)

Thankyou !!!

Hope You have Learned !!!