Lab Guide

  1. Deploy a CloudFormation stack called catsndogsECStasksandservices to create the ECS tasks and services for catsndogs.lol, as well as the CloudWatch alarms that will be used for Task Auto Scaling.

    Region Launch Template
    Oregon (us-west-2) Launch Catsndogs Services Stack into Oregon with CloudFormation
    Ohio (us-east-2) Launch Catsndogs Services Stack  into Ohio with CloudFormation
    Ireland (eu-west-1) Launch Catsndogs Services Stack  into Ireland with CloudFormation
    Singapore (ap-southeast-1) Launch Catsndogs Services Stack  into Singapore with CloudFormation
  2. Find the load balancer with catsn-catsn in the name. Copy the DNS name into your browser and validate that the site works.

  3. In the ECS Console, select the cats service and enable Task Auto Scaling, via the Update button at the top right hand corner. Move through the steps, and set the Service Auto Scaling to “Configure Service Auto Scaling to adjust your service’s desired count”. Set the minimum number of tasks to 2 and the maximum of 100. Select the role with ECSAutoScaleRole in it’s name.

    a. Create a policy called ScaleUp. Use the alarm with “CatsScaleUp” in the name. Add steps to the scaling policy. The first step should add 10 tasks when the load is between 1000 and 2000. The second should add 20 tasks when the load is between 2000 and 4000. The third should add 25 tasks when the load is over 4000.

    b. Create a policy called ScaleDown. Use the alarm with “CatsScaleDown” in the name. Add steps to the scaling policy. The first step should remove 10 tasks when the load is between 1000 and 100. The second should remove 5 tasks when the load is under 100.

  4. Repeat step 3 for the dogs service.

  5. Deploy a second CloudFormation stack to generate load against the website.

    Region Launch Template
    Oregon (us-west-2) Launch Load Generator Stack into Oregon with CloudFormation
    Ohio (us-east-2) Launch Load Generator Stack into Ohio with CloudFormation
    Ireland (eu-west-1) Launch Load Generator Stack into Ireland with CloudFormation
    Singapore (ap-southeast-1) Launch Load Generator Stack into Singapore with CloudFormation
  6. In CloudWatch view the metric RequestCount for the load balancer’s Target Groups. Ensure you set the Statistic to Sum, and the Period to 10 seconds.

  7. Check the CloudWatch alarms for scaling up the cats and dogs services. They should enter ALARM state two to three minutes after the threshold is first breached.

  8. In the ECS console, check that the ECS services are adding more tasks in response to the load. The Events tab for each service will show information about new task launches.

  9. In CloudWatch, check the ScaleOut alarm which is triggered by the cluster’s MemoryReservation metric. This should move into ALARM state as tasks are added to the ECS services, causing the amount of reserved memory to increase.

  10. Once the ScaleUp alarm is triggered, check the Spot fleet Auto Scaling history. Instances should be added to the Spot fleet

  11. Check the cluster’s ECS Instances tab, to see that the new instances have joined the ECS cluster.

  12. Once you have seen the Spot fleet scale up, stop the LoadGenerator EC2 instance.

    You should now have ECS Services defined for cats and dogs, and seen how ECS task Auto Scaling and EC2 Auto Scaling help as the system comes under load.

What’s Next

Deploying a new version of the cats service with secrets management

Detailed Instructions

ECS Service deployment and task Auto Scaling - Detailed Instructions