Using Auto Scaling Group To Dynamically Create EC2 To make A Website Highly Available, Scalable, Fault Tolerant and Elastic.

Using Auto Scaling Group To Dynamically Create EC2 To make A Website Highly Available, Scalable, Fault Tolerant and Elastic.

ยท

3 min read

Ensuring the availability, scalability, fault tolerance, and elasticity of a website is paramount for businesses and companies to meet the demands of their users. Auto Scaling Group (ASG) allows for automatic adjustment of the number of EC2 instances in response to demand, traffic and predefined metrics. By dynamically creating and terminating EC2 instances, ASG ensures that the website can handle varying levels of traffic efficiently while maintaining performance and minimizing costs.

Procedures

Some of the setting and configuration inputs that are used in this project has already been created in the Project 1 & 2.

  • Before creating an ASG, we will need to first create a Launch Template.

  • On EC2 menu list, navigate to Launch Templates and click Create launch template.

  • Give the template a name and description. ie. Ejim-Launch-Template and Check the Auto Scaling guidance box.

  • Select any OS system of your choice for your Instance, in this case Amazon linux and select instance type.

  • Select key pair and add the Web server SG which we created in the previous projects.

  • Under Advanced details, scroll all the way down to user data and paste the bash script commands to install our website.

  • Click Create launch template.

Now that we have created the launch template, we need to create the Auto Scaling Group ASG.

  • Navigate to Auto Scaling Group and click Create Auto Scaling Groups.

  • Give the Auto Scaling Group a name .ie. Ejim-ASG

  • Under Launch Template, select the launch template we created earlier .ie. Ejim-Lauch-Template and click Next.

  • Under VPC, Select our VPC .ie. Ejim VPC and under Availability zone, select both of our private App subnets .ie. Private App Subnet AZ1 and Private App Subnet AZ2. Click Next.

  • Under Load balancing, select Attach to an existing load balancer, and select our Target group we created previously .ie. Ejim-TG

  • Under Health checks, tick the ELB. Under Monitoring, tick Enable group metrics collection within Cloudwatch. Then click Next.

  • To configure the EC2 group size and scaling policies

  • We set the Desired capacity (desired number of Ec2 instance) to 2.

  • We set the Minimum capacity (least number of instances we can automatically downscale to during low traffic) to 1.

  • We set the maximum capacity (highest number of instances we can automatically upscale during high traffic) to 4.

  • Click Next and click Add notifications (This sends a notification whenever EC2 Auto Scaling launches or terminates the EC2 instances in our Auto Scaling Group).

  • Click Next and Add a Tag to specify the name of the EC2 instances created by our Auto Scaling Group would bear. ie. ASG-Webserver.

  • Click Next, review the configurations and click Create Auto Scaling group.

    As we can see, we were able to get to our website.

ย