To configure Auto scaling in AWS first we have to configure and setup following features of
An Instance- This will be instance for which we will configure Auto scaling.
Instance Image- Have to take the image of the instance for which we have to configure Auto scaling. We call it as AMI’s.
Load balancer- Have to configure load balancer to attach it with the Auto scaling group.
Launch configuration- Have to setup launch configuration for the Auto scaling group.
Auto scaling group- Then at last we have to setup Auto scaling group and give all the configuration details.
I have configured Auto scaling in our test environment for demonstration. We will see it step by step.
STEP 1:- Select an Instance
I have created an instance with name Production. This will be the instance for which we will setup and configure Auto scaling.
STEP 2:- Take the Instance Image
Take the Image of the Instance by selecting the Instance and go to Actions then select Image and click on Create Image.
After clicking on Create Image a prompt will open where we have to specify the Image name. I have given name Production-Image.
After creation of the Image we can see it in AMI’s option under IMAGES
STEP 3:- Setup the Load balancer
To setup the load balancer click on Load balancer on the left side of console and then click on Create Load Balancer. The new console will open for setup:-
- In first step give the name for the Load balancer then VPC if we have and specify the port to be open for the server. By default http port is open as per screen shot below. Then click next.
2. Select a security group according to your environment setup or you can create a new security group. Else it will select the default security group by its own.
3. Step 3 is to configure the Security setup if we are using the HTTPS or SSL protocol. Here we are not using these two ports so we can skip it. Click next.
4. Health check is the facility in which the load balancer check the status of the instance in every given interval with provided protocol and port number. If the check is not successful it will terminate that instance.
In this step we have to specify the ping protocol, ping port and time intervals.
I have configured to check health status with TCP protocol with 22 port.
5. In this step we have to add Instance which we have to keep under load balancer.
We will just skip this step here as we will link this with Auto scaling group so that all the scale up Instance will listed here automatically.
6. In this step we have to put tag if we want. This will be helpful in a big environment to recognize the load balancer instances. We are putting a simple tag in it.
7. In this step you can review the setup, if everything is ok click on Create.
Now the load balancer has been configured and you can see it under load balancer with provided name.
STEP 4:- Setup the Launch configuration
To setup and create new launch configuration. Go to Launch configuration under Auto scaling.
Click on Create launch configuration to setup a new launch configuration.
- In first step we have to select the AMI which will launch during the Auto scaling. We have to select My AMIs and select our Image which we stored before with name Production-Image.
2. In second step we have to select the instance type. We can leave it as default and select next.
3. In this step it will ask for the Launch configuration name. Give a name and select next.
4. In this step it will ask to add storage according to our requirement.
5. Now here we have to select a security group according to our environment setup and open port if we want.
6. This step is to review the setup. If everything is Ok. Click Create launch configuration.
The setup of launch configuration is done. You can see it Left side of console under Auto scaling.
STEP 5:- Setup Auto scaling Group
To setup Auto scaling click on Auto Scaling Group option under Auto Scaling on left side of the console and click on Create Auto Scaling group.
In first console it will ask to select a launch configuration. Select the launch configuration which we created in previous step.
- In this step give the Auto scaling group name, select the subnet, then in advance details enable Load balancer and specify a load balancer which we have configured in previous steps and leave others as default.
2. In this step we have to setup the policy according to which the instances will get added and removed automatically.
For both the column we have to setup the alarm as per the screen shot.
Click on Add new alarm and setup the alarm as per requirement.
Here I am giving the policy that if the CPU utilization will go above 70% for 60 seconds then it will add one instance and if CPU utilization will go below 30% then it will remove instance according to given desired instance capacity.
Then configure the alarm for Decrease Group size value
Now as the alarm is configured select the number of instances to be add or remove from the group. Also put minimum size as 1 and maximum size as 2 so that during Auto scaling it will go up to max 2 instance only.
3. In this step we have to specify an email ID where we will get the notification for every action or change done by Auto scaling policy.
4. In this step you can put a tag for this group.
5. This step is just to review the details. If everything is OK click create Auto scaling group.
After successfully creation of Auto scaling group you can see a new instance starts creating under that policy as we had given 1 desired instance which means always there should be 1 instance available.
Testing of Auto scaling as per our given scenario.
As per our given scenario we are maintaining one instance and during the high CPU one more instance will be added as a load balancer and when the CPU will go down it will terminate one instance from the group and left with maintaining one instance.
So for the testing purpose we will manually make CPU high of the server which is under Auto scaling group so that Auto scaling policy will monitor and add one more instance.
After waiting for some time we can see under the instance tab that one more instance will get added.
Then make the CPU less than 30% by killing the process and wait for some time then we can see that again the instance count will go back to one by terminating the old instance.
You can track all the actions of the Auto scaling from Activity History tab or you will also be notified about all the action of Auto scaling to the mail Id provided during the configuration.
In this way the Auto Scaling will add and remove instances according to given condition.
If we are running Auto scaling with load balancer for web server then we have to link load balancer DNS name with our public URL in Route 53 service of AWS to publish our web page through public URL.
The load balancer will work in round robin method and distribute the load among all the server under it.
We will get the DNS name under our configured Load balancer as per below screen shot.
Any Help or Suggestions?Connect with me : https://www.linkedin.com/in/sumeet-sahu-bb256523/