Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

AWS Logo
Menu
ECS Fargate Cost Optimization with Scheduled Scaling

ECS Fargate Cost Optimization with Scheduled Scaling

Guide for scheduled scaling in ECS Fargate development environments

Published Mar 22, 2025
In Amazon ECS Fargate, scheduled scaling enables adjustments to the number of tasks assigned to a service. This capability uses AWS's "Application Auto Scaling" service, which automatically scales resources beyond Amazon EC2.
As I noted in a previous article, we frequently face the challenge of reducing costs in non-production environments. Therefore, it is crucial to take proactive measures, such as stopping services that do not need to be available at all times.
Implementing Scheduled Scaling
Think about a development environment that operates exclusively Monday to Friday, between 7:30 am and 6:00 pm. You can establish a scaling schedule in Amazon ECS Fargate to satisfy these conditions:
  • Service shutdown: Every weekday at 6:00 pm, a scheduled action adjusts the set minimum and maximum capacity to "0".
  • Service startup: Every weekday at 7:30 am, a scheduled action adjusts the minimum capacity to "1" and the maximum capacity to "1 or more."
Here is an example of code that can be implemented with Terraform:
You can view the scheduled actions' creation through the AWS management console:
Amazon ECS Fargate Scheduled Scaling
The complete example is available in the repository below:
I hope this article proves helpful to you. Best wishes, and see you next time. Thank you!
 

Comments