Tech Junkie Blog - Real World Tutorials, Happy Coding!: Iaas With AWS: Setup Auto Scaling With Application Load Balancer

Monday, December 14, 2020

Iaas With AWS: Setup Auto Scaling With Application Load Balancer

 In this pose we are going to implement auto scaling on our instances.  Auto scaling is a feature on AWS that automatically scaled horizontally either based on metrics or the health of an instance. In this post we are going to setup auto scaling on an Application Load Balancer.  

1. The first thing we have to do is setup an Auto Scaling Group under "Auto Scaling" click on "Auto Scaling Groups"

2. Click on the "Create Auto Scaling group" button

3. Give your auto scaling group a name, then click on the "Create a launch template"



3. Give your template a name, then scroll down to AMI type


4. Select Amazon Linux 2 as the image, t2.micro as the instance type, and specify the "Key pair(login)"

5.  Accept the default VPIC, and expand "Advance Details" and paste the following into the "User Data" to install Apache Web Server, then click on "Create launch template"

#cloud-boothook
#!/bin/bash
#Use this for your user data (script without newlines)
# install httpd (Linux 2 version)

yum update -y 
yum install -y httpd.x86_64 
systemctl start httpd.service 
systemctl enable httpd.service 
echo "Hello world from $(hostname -f)" > /var/www/html/index.html
cd /var/www/html/
cp index.html contacts.html

6. Click on "Create Auto Scaling Group"

7. Continue creating your Auto Scaling Group, as you will see the template has been selected for you, click "Next", accept the default then click "Next"



8. Accept the default, and then select the subnets you want your instances to be created in, then click "Next"
9. On the group size, type following value. We basically say we want 3 capacity, and the max an min instances is between 2 and 4.

10.  For scaling policies, set a policy to scale when the CPU is 50% or more
11. Click "Next" until you see the "Review" page, then click on  "Create Auto Scaling group" then click on the button.

12. If you select the Auto Scaling group and click on the "Activity" tab you will see that it is in the process of creating three instances that we specified as our desired capacity.


13. If you look at the instance you will see that three new instances have been created


14.  So now we can create our load balancer to tie all of this together
15. Create an Application Load Balancer, when choosing the subnet, make sure you choose the same subnets as the ones you used for your Auto Scaling Group.  If you need directions on how to create an Application Load Balancer, you can go to this post.

16.  Choose the Security Group that has HTTP traffic on port 80
17. For routing create a new Target group and accept the default
18.Under "Advanced health check settings" change the "Healthy threshold" value to 3, then click "Next"

19. Skip the "Register Targets" because we want the load balancer to pick up the instances that the Auto Scaling group creates, click "Next" until you see the "Create" button, click on it.
20.  Go back to the Auto Scaling group page, then select the Auto Scaling group and click on the "Edit" button.




20.  Under  "Load balancing" select the Target group that you created in the load balancer, then click "Save"

21. Now we can test to see if the Auto Scaling work, the easiest way to test it is to terminate one of the instances.  Since we specify that we desired at least 2 (the minimum), a new instance should be created automatically

22. As you can see a new instance is automatically created

If you want to test the CPU utilization metrics you can follow the instruction here to put stress on your server https://acloudxpert.com/install-stress-utility-on-amazon-linux-2/
 





14 comments:

  1. Thank you for sharing your info. I really appreciate your efforts and I am waiting for your further write ups thank you once again. And know Mimz International Merchandising Company provides services to clients to Make their Vision a Reality and to help companies to improve business performance. merchandising

    ReplyDelete
  2. Wow, impressive!!! Amazing post, I found a lot of interesting information here. I really appreciate your article. Going to read more new posts.

    Find out Dream 11 predictions for today's match & fantasy cricket tips. We Provides 100% true match prediction with free fantasy tips. We cover all major cricket tournaments and matches.

    ReplyDelete
  3. Food and recipes
    Thank you admin for your useful information . I think your dedication is inspiring. This note is just an extension of what we all already know. We couldn’t do it without you.

    ReplyDelete
  4. Hi,
    Thanks for sharing this beautiful and informative article.
    I have really enjoyed reading the article and of course learned several new things from your content.
    I would definitely share this blog on my social media pages.
    Looking forward and waiting for your new blogs
    Thank you

    ReplyDelete
  5. Hi,
    Thanks for sharing this beautiful and informative article.
    I have really enjoyed reading the article and of course learned several new things from your content.
    I would definitely share this blog on my social media pages.
    Looking forward and waiting for your new blogs
    Thank you

    ReplyDelete
  6. Hi,
    Thanks for sharing this beautiful and informative article.
    I have really enjoyed reading the article and of course learned several new things from your content.
    I would definitely share this blog on my social media pages.
    Looking forward and waiting for your new blogs
    Thank you

    ReplyDelete
  7. Here you Provided really good information, really appreciate your efforts it. Properties in Udaipur and Affordable housing in Udaipur

    ReplyDelete

  8. hi thanks for sharing i found something new on my blog driver booster pro key

    ReplyDelete
  9. Hi,
    Thanks for sharing this beautiful and informative article.
    I have really enjoyed reading the article and of course learned several new things from your content.
    I would definitely share this blog on my social media pages.
    Looking forward and waiting for your new blogs
    Thank you



    ReplyDelete
  10. Welcome to We Buy Houses Palm Beach, the Official Cash Home Buyer of Palm Beach, Florida, and surrounding areas.

    We provide home sellers with a cash option to purchase their property quickly—with NO Repairs, and NO Fees or Commissions.

    Simply go to our website or call us at (561) 232-3350 to get a no-obligation cash home offer sent to you. It’s free and confidential.

    Avoiding foreclosure? Facing divorce? Moving? Upside down in your mortgage? Liens? It doesn’t matter whether you live in it, you’re renting it out, it’s vacant, or not even habitable. We help owners who have inherited an unwanted property, own a vacant house, are behind on payments, owe liens, downsized, and can’t sell… even if the house needs repairs that you can’t pay for… and yes, even if the house is fire damaged or has bad rental tenants.

    Basically, if you have a property and need to sell it… we’d like to make you a fair cash offer and close on it when you’re ready to sell.

    Just contact us today to get started!

    ReplyDelete
  11. Bethel Home Healthcare, LLC. is licensed through the Department of Mental Health for the state of Missouri. Bethel was founded by Darlene Davis in 2017 with a vison to improve the quality of life of individuals struggling with mental health and intellectual disabilities.

    ReplyDelete
  12. Hi,
    Thanks for sharing this beautiful and informative article.
    I have really enjoyed reading the article and of course learned several new things from your content.
    I would definitely share this blog on my social media pages.
    Looking forward and waiting for your new blogs
    Thank you

    ReplyDelete
  13. Didn't know this was even possible, thanks for sharing.
    buy logo

    ReplyDelete

Search This Blog