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.
Find the load balancer with catsn-catsn in the name. Copy the DNS name into your browser and validate that the site works.
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.
Repeat step 3 for the dogs service.
Deploy a second CloudFormation stack to generate load against the website.
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.
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.
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.
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.
Once the ScaleUp alarm is triggered, check the Spot fleet Auto Scaling history. Instances should be added to the Spot fleet
Check the cluster’s ECS Instances tab, to see that the new instances have joined the ECS cluster.
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.