What is Auto Scaling? AWS Auto Scaling using EC2 Instance

What is Auto Scaling? AWS Auto Scaling using EC2 Instance: Auto Scaling with Amazon EC2 Instance is a way to increase the availability of your application during heavy traffic. Auto Scaling ensures that your application has a sufficient number of instances to handle the incoming requests over the network. You can write up-scaling or down-scaling policies for an application. In AWS the collection of EC2 instances is called Auto Scaling groups.

AWS Auto Scaling Groups

An Auto Scaling group is a collection of EC2 instances that have exactly same configurations. You can write policies for increasing and decreasing the number of running instances in an Auto Scaling group based on few factors like CPU utilization, number of incoming request or downtime. The main service of an auto scaling group to maintain the number of instances automatically. You can also fix the lower limit and upper limit for a number of instances in an auto scaling group.

AWS Auto scaling Group

Steps to create AWS Auto Scaling groups

  1. Open Amazon EC2 console and select Auto Scaling option from the left panel and click on Create Auto scaling group button 1-Launch-config
  2. Click on Create launch configuration Before creating the Auto Scaling group, we need to create the launch configuration 2-create-Auto-scaling-before-launch-config-2
  3. Select Amazon Linux AMI option as shown in below image 3-slect-AMI-Instance-3
  4. Select t2.micro type because it freely available service by AWS, others may cost you. Move next with Configuration details 4-select-t2-micro-4
  5. Give a name for your launch configuration, other options are as per requirements and move to the next step5-my-config-settings-5
  6. You can change or skip properties for Add storage option. Move to the next step 6-create-select-security-gp-6
  7. Now you can configure a new security group or select an existing security group as shown in below screenshot 6-create-select-security-gp-6
  8. Select or create key-pair for your Auto Scaling Group 7-create-key-pair
  9. Review or modify the settings. Click on Create launch configuration button to launch the configurations 8-Review-8
  10. After Create launch configuration step, you will get Create Auto Scaling Group tab. Give a name for your auto scaling group, set group size , and select as much as subnet to increase the availablity of your application. Now move to the next step 9-create-auto-scale-gp1
  11. Configure scaling policies this option allows you to limit your auto scaling group
    • Select second option as given below. Define the minimum and maximum range for group. Then click on Scale the Auto Scaling group using step or simple policies Scaling-policies
    • Increase Group Size – if CPU load>=5 for 1 minutes the Auto Scaling group will add 1 instance to that group to manage the load. Click on Add new alarm option to add policy 10.1-increase-instance
    • Decrease Group Size- if CPU load<=5 till 1 minutes the Auto scaling group will remove 1 instance from the group 10.2-decrease-policy
    • The final configuration will be as shown in below screenshot 10.3final
  12. Here you can configure notifications for your policies 11-add-notification-to watcher-12
  13. Configure a Tag for your auto scaling group. AutoScaleInstance is a tag for my Auto scaling group 12-configure-Tag-13
  14. Review all configuration for Auto scaling group and click on Create Auto Scaling group button 14-review-comlete-14
  15. After above step you will get below Dashboard for Auto Scaling group 15-created-final-auto-scalling-gp
  16. Goto the Instances option from left panel, here you will see details for your Auto scaling group 16-Auto-scalling-instance

Testing Auto Scaling Servers during load

To test Auto Scaling group, how it works?. Connect to your auto scaling instance though putty and install stress package to increase CPU load.

To install stress package execute following commands –

$sudo yum install stress

To increase the load on CPU –

$stress -c 2 -i 1 -m 1 –vm-bytes 128M -t 10s

you will see multiple instances in Autoscaling group, when CPU load increase more than 5% . and when the load decreases instances get terminated automatically 17-AutoScalling-load-test-16

we are open to any suggestion because it can improve a bit more. ww.ease2code.com 

Speak Your Mind