AWS comes with the great service of auto scaling, that gives the possibility to automatically adapt the environment to the changing needs.
This helps to optimize costs and performance. With rising needs, your environment scales up and as soon as the needs decrease again, your environment will scale down again.
The benefits of EC2 Auto Scaling are quite simple:
1. Right-sized resources at any time
2. Controlled costs, because unneeded resources are removed automatically
And the best: Auto Scaling itself is free. You only pay for the costs your generate using the application resources and CloudWatch.
In this article we gonna build a really basic Auto Scaling Group that helps to have (at least) one instance running all the time.
To setup the Autoscaling Group we ned two main steps:
1. Build the Launch Configuration
2. Create the EC2 Auto Scaling Group
Build the Launch Configuration
So let’s have a look on how we can setup an EC2 auto scaling group to get the environment more flexible and elastic. Therefore navigate to the EC2 service and on the left bar, scroll down to the bottom on the left and click on “Launch Configuration”
Now you can configure what you want to launch during the auto-scaling.
1. Give the configuration a name and select the AMI needed for launch of a new EC2 Instance. Also select the instance type which should be launched.
2. Next the EBS volumes can be defined and/or the size could be adjusted.
In this example, we only select the root volume.
3. Choose the Security Group (for more information, click here) .
In this example we choose the default one, but also own security groups can be selected.
Create the EC2 Auto Scaling Group
Now we can go on with the Auto Scaling group.
Therefore select the configuration created in the above step and go on with configuring the auto scaling group.
Click on “Actions” on the right corner and afterwards on “Create Auto Scaling group”.
While creating the group we have to go through different steps. The first two steps are mandatory all others are optional.
In this article we go with the defaults to keep it simple. Of course you can configure the size of the group and notifications fitting to your needs.
Click on “Create Autoscaling group”.
That’s it. The scaling group is ready and running.
– As soon as you terminate your instance, you can see a new instance launching automatically.
– To check which instances belong to your created scaling group, just go to the EC2 Dashboard – running instances and select for aws:autoscaling:groupName and you’ll get the overview of all instances belonging to that group.