AWS Classroom Series – 18/Apr/2020

Scaling

  • Scaling is of two types
    • Horizontal: Increasing number of servers with same application to distribute the load
    • Veritical Scaling: Increasing systems resources like cpu, ram etc. In Aws, you can do this changing instance size
  • Why scaling ?
    • Because you might need more performance, availiability, load increased etc

Scenario:

  • Our Organization (QT) has an ecommerce application with the folowing architecture Preview

  • Due to offers on your ecommerce application load increased, when load increases it is better to increase virtual machine (ec2 instances) Preview

  • How to do this in AWS?

    • EC2 Auto Scaling
  • Autoscaling relys on

    • AMI’s: To create a new instance with same software/application we would need AMI’s first
    • Auto Scaling Group: Each Auto Scaling group represents an application component (webserver/appserver). Auto scaling group will have following information
      • Minimum number of ec2
      • Desired Capacity of ec2
      • Maximum number of ec2 instances
    • Cloudwatch metrics/alerts: These help in deciding when to scale.

Lets do this practically

  • Creating an ubuntu image with lamp stack installed based out of steps from here.
  • In this scenario i will be creating an artifical load and for that i will be using a tool called as stress
  • commands executed after ssh into ec2 ubuntu instance
sudo apt-get update
sudo apt-get install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
sudo systemctl restart apache2
sudo systemctl enable apache2
sudo apt install php-cli -y
sudo vi /var/www/html/info.php => 
<?php
phpinfo();
?>
sudo systemctl restart apache2
sudo apt-get install stress -y

  • Create an AMI of the Ec2 instance

  • Assume you need to increase your ec2 instances by 1 when the cpu utilization average is greater than 75% for atleast 5 mins and decrease your ec2 instances by 1 when the cpu utilization is less that 50% for atleast 5 mins

  • Now Navigate to the Autoscaling section Preview Preview

  • Autoscaling groups requires launch configuration or launch template

  • Click on Create Autoscaling group Preview

  • Create a new launch configuration and select AMI Preview

  • Choose the size which fits your application. (I use t2.micro for demo) Preview

  • Create launch configuration and select storage, security group (create) Preview Preview Preview Preview

  • Create a Autoscaling group for a launch configuration Preview

  • Select scaling policies Preview Preview

  • For this case we have decided "increase your ec2 instances by 1 when the cpu utilization average is greater than 75% for atleast 5 mins and decrease your ec2 instances by 1 when the cpu utilization is less that 50% for atleast 5 mins", so lets implement Preview Preview

  • Add Notificiations if required

  • Review the settings and create autoscaling group to see instances to be created (in action) Preview

  • Now have a look at ec2 instance autoscaling group view Preview

  • Wait till Desired (Expected) reaches the current count Preview

  • Now find the instance id and navigate to it Preview

  • Now find public ip and navigate to “`http://publicip/info.php“ Preview

  • If you want to do the same from cli refer here Preview

Next topics

  • How to scale and load balance

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Widget by Acurax Small Business Website Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube