Now we are going to look into ECS Auto Scaling! Auto-scaling is the ability to increase or decrease the desired count of tasks in your Amazon ECS service automatically. This enables resources to be created when required and then later destroyed. In this part, you will learn how to use AWS Auto Scaling to enable auto-scaling for the inventory service.
To enable auto scaling, you need to navigate to Elastic Container Service in the AWS Management Console.
In the Elastic Container Service Console, click on the cluster, “UnishopCluster”. You will find the “InventoryService” that you deployed in the previous part of the lab under the “Services” tab.
Click on the “InventoryService” to load the Service information page. Next, you will update the service to enable Auto Scaling. Click the “Update” button.
You will be navigated to an “Update Service” page where you will be able to view/update all the configurations that were done in part 2 of the lab. Click “Next Step” twice to get to the “Service Auto Scaling” (optional) step. Here you will configure auto scaling.
Select “Configure Service Auto Scaling” option. First you will configure the task counts. For the purpose of the lab, keep the “Minimum number of tasks” as 1 and “Maximum number of tasks” as 5. Then, click “Add scaling policy”.
Do the following changes. Then click the “Save” button.
“Scaling policy type”: Select “Taget tracking”
“Policy name”: Enter RequestCountTrackingPolicy
“ECS service metric”: Select “ALBRequestCountPerTarget”
“Target value”: Enter 100
“Scale-out cooldown period”: Enter 60
“Scale-in cooldown period”: Enter 60
Click the “Next Step” button. You will get a final review page, click the “Update Service” button to finish configuring autoscaling.
After a few seconds, the update is completed. Click on “View Service”.
You will be navigated back to the Service page. Click on the “Auto Scaling” tab to view the configured policy.
Now that you have enabled auto scaling, let’s witness an auto scaling happening in real time in the next part of the lab.