Configuring Auto Scaling Rules for an AWS Fargate Cluster
AWS Training Architect II in Content
In this hands-on learning activity, the student will configure auto scaling rules for a service, and trigger those rules by applying a load to that service.
Configuring Autoscaling Rules for an AWS Fargate Cluster
In this hands-on lab, we will configure auto scaling rules for a service and trigger those rules by applying a load to that service.
Log in to the live AWS environment using the credentials provided. Make sure you're in the N. Virginia (
us-east-1) region throughout the lab.
You'll need to use the ApacheBench (
ab) utility later on. This command is installed by default on macOS, and it is also available for many Linux distributions. For example, you can install
ab on Amazon Linux with the following command:
sudo yum install -y httpd24-tools
Configure Service Auto Scaling
- In the AWS console, navigate to ECS and click the listed cluster.
- In the Services section, click to open the webapp service.
- Click Update.
- Click Next step on the Configure service and Configure network pages.
- For Service Auto Scaling, choose Configure Service Auto Scaling to adjust your service’s desired count.
- Set the following values:
- Minimum number of tasks: 1
- Desired number of tasks: 1
- Maximum number of tasks 2
- IAM role for Service Auto Scaling: Choose the listed role
- Click Add scaling policy.
- On the Add policy page, set the following values:
- Scaling policy type: Target tracking
- Policy name: TargetTrackingPolicy
- *ECS service metric: CPUUtilization**
- Target value: 75
- Scale-out cooldown period: 60
- Scale-in cooldown period: 60
- Click Save.
- Click Next step.
- Review, and then click Update Service.
- When your service status is finished updating, click View Service.
Trigger a Scaling Activity for Your Service
From your service's main view page in the console, choose the load balancer name to view its details in the Amazon EC2 console. You need the load balancer's DNS name.
Use the ApacheBench (
ab) utility to make thousands of HTTP requests to your load balancer in a short period of time.
Run the following command, substituting your load balancer's DNS name.
ab -n 1000000 -c 2000 http://&lt;YOUR_ALB_ENDPOINT_HERE>.us-east-1.elb.amazonaws.com/
In the AWS console, navigate to CloudWatch.
Click Alarms in the left-hand menu.
Wait for your
abHTTP requests to trigger the scale-out alarm in the CloudWatch console. You should see your Amazon ECS service scale out and add one task to your service's desired count.
Shortly after your
abHTTP requests complete (>= 10 mins), your scale-in alarm should trigger. The scale-in policy should reduce your service's desired count back to one.
Congratulations on completing this hands-on lab!