Part 3 - Enable auto scaling for ECS tasks

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.

Enable Auto Scaling

  1. To enable auto scaling, you need to navigate to Elastic Container Service in the AWS Management Console.


  2. 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.


  3. Click on the “InventoryService” to load the Service information page. Next, you will update the service to enable Auto Scaling. Click the “Update” button.

    Services config

  4. 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.

    Update service

  5. 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”.

    Task count

  6. 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

    Add Scaling policy

    Target policy

  7. Click the “Next Step” button. You will get a final review page, click the “Update Service” button to finish configuring autoscaling.

    Next Step Service Auto Scaling


  8. After a few seconds, the update is completed. Click on “View Service”.


  9. You will be navigated back to the Service page. Click on the “Auto Scaling” tab to view the configured policy.

    Auto scaling finished

  10. Now that you have enabled auto scaling, let’s witness an auto scaling happening in real time in the next part of the lab.