Setup Autoscaling

Setup Autoscaling

No alt text provided for this image

  • In real life you're load on the websites can change over time. So for example, say your users are doing shopping, they're most likely doing shopping during the day and not at night. So you expect more load during the day and less load during the night.
  • So in the cloud we know we can create and get rid of servers very quickly and so the goal of an auto scaling group is to scale out. That means add EC2 instances to match an increased load or scale in, that means remove EC2 instances to match a decreased load.
  • With this we can ensure that we have, also as well, a minimum, and a maximum number of machines running at any point of time and once the auto scaling group does create, or remove EC2 instances we can make sure that these instances will be registered, or de registered into our load balancer.
  • So these two things work hand in hand. Finally, in case one of our servers becomes unhealthy, maybe there's an application bug, then the auto scaling group can detect it and say, yeah, you know what, I don't need an unhealthy instance. I'm going to de register it. I'm going to terminate it and replace it by a new healthy one.

So with an auto scaling group we get a lot of benefits and another benefit we get, is that we have huge cost savings, because we are only running all the time at the optimal capacity and that is one of the guiding principle of the cloud, elasticity.

No alt text provided for this image

Autoscaling mainly comprise of 4 important steps:

1. Launch an instance.

2. Create an image.

3. Launch Configurations

4. Autoscaling Groups

Launch an Instance

  • Logging in to AWS, select EC2 in the AWS services. To launch a new configuration, click on?Launch Instances.

No alt text provided for this image

  • Choose an Amazon Machine Image(AMI). (?Microsoft Windows Server 2016 Base)?to have Graphical Interface.

No alt text provided for this image

  • Choose Instance type t2.micro. Click on?Next.

No alt text provided for this image

  • We will launch only 1 instance and let Autoscaling group launch instances according to requirements. Click on?Next: Add Storage.

No alt text provided for this image

  • By keeping?Add Storage?and?Add Tags?to default.

No alt text provided for this image
No alt text provided for this image

  • In Configure Security Group, We will create a new security group named?demoASG, keeping Description to default. Choose?RDP?for remote connection to Windows system and?HTTP?and?HTTPS?to allow internet traffic to reach our instances. Select?Source?to Anywhere for all the 3 types as shown below.

No alt text provided for this image

  • Choose a key-pair. Create a new key-pair and give it a name of your choice. Download key-pair and launch instances.

No alt text provided for this image
No alt text provided for this image

  • Give name to the launched instance to avoid any confusion.

No alt text provided for this image

Creating Image

  • Select the running instance and Click on?Actions?and select?Images and Templates?and?Create Image.

No alt text provided for this image

  • Enter any name of your choice in Image name. I will choose demoASG. Keeping all other settings to default, Click on?create instance image.

No alt text provided for this image

  • AMI image is successfully created.

No alt text provided for this image

Creating Launch Configuration

No alt text provided for this image

  • In the left navigation Panel, under?Autoscaling?select?Launch Configurations. Click on?Create Launch Configuration.

No alt text provided for this image

  • Give a Launch Configuration name and Choose AMI name of the one we created above. Here will select?demoASG.

No alt text provided for this image

  • Select Instance type as?t2.micro. Keeping?Additional Configuration?and?Storage?to default, we will choose existing security group, the one we created while launching our instance.

No alt text provided for this image

  • Use existing key-pair, same as one created while launching an instance. Click on?Launch Configurations.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Creating Auto Scaling Group

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

DEMO

No alt text provided for this image
No alt text provided for this image

  • Enter?group name?and?Switch to launch configurations?and select the configuration name we created in Step 3. Click on?Next.
  • Choose?VPC?as default and select all the available?subnets?to balance the load. Click on?Next.

No alt text provided for this image

  • We are not using Load Balancers. In Health Check,?Health Check type?by default will be EC2 because we have launched an instance and will select?Health Check grace period?as 120 seconds.?Click on?Next.

No alt text provided for this image

  • We will keep?Desired Capacity?2 as we want Autoscaling group to make 2 instances available to us.?Minimum Capacity?as 1, available instances should never be less than this size and?Maximum Capacity?as 5, number of instances should never exceed this size.

No alt text provided for this image

  • Selecting?Target Tracking Scaling Policy?and using?Average CPU utilization?as Metric Size and setting?Target Value?as 50, an instance will be launched if CPU utilization exceeds Target Value. Instances need 120 seconds warm up before including in Metric. Click on?Next.

No alt text provided for this image

  • Keeping other settings by default. Click on?Create Autoscaling Group.
  • Autoscaling group is created. We will see new instances being launched. If we increase load on server, more instances will be launched according to need.

No alt text provided for this image

Connecting to original instance using RDP.

  • Select the instance and click on?Connect.

No alt text provided for this image
No alt text provided for this image

  • In RDP client, click?Get Password.
  • Browse the key-pair you used while launching the instance and click on?Decrypt Password.
  • Download the Remote Desktop file and copy the password.
  • Open Remote Desktop file and proceed. Enter the copied password when asked for. Windows Server is connected to our system.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

  • To increase CPU utilization, create a .bat file and open the file multiple times. When CPU utilization increase to a limit, new instances will be launched.

No alt text provided for this image





Ashutosh Singhal

Professional Cloud Architect | Dev-Sys-Net-Sec-Fin Ops | Technical Content Creator | Corporate Trainer | Influencer |

3 年

Good work dhruv....??

要查看或添加评论,请登录

Dhruv Bhatia的更多文章

社区洞察

其他会员也浏览了