4

I'm running Superset in AWS ECS using Fargate. This instance of Superset is for internal use only. I want to be able to configure ECS to scale to zero tasks when not in use. I am aware that it will take time (Possibly minutes) to come back up, the end-users of this application are content with waiting a few minutes.

Situation:

  • AWS ECS deployed using Fargate
  • Autoscaling set to a max of 2 and a min of 0
  • Want to scale to 0 when not in use (after, say, an hour)
Jelkimantis
  • 138
  • 1
  • 10
  • 1
    This isn't something ECS supports. It has nowhere to store the new "requests" that come in while it spins up new instances. If there are 0 instances then the requests would simply be discarded. You would need to look into AppRunner for this functionality. – Mark B May 19 '22 at 21:39
  • 1
    I'm investigating on the same thing, and by reading the docs seems somehow possible: `If you want your task count to scale to zero when there's no work to be done, set a minimum capacity of 0. With target tracking scaling policies, when actual capacity is 0 and the metric indicates that there is workload demand, Service Auto Scaling waits for one data point to be sent before scaling out. ` from: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html . However not sure how to make it works. – sgargel Jun 20 '23 at 12:08
  • Thanks for posting this quote! I think the key part ist "With target tracking scaling policies [...]", i.e. you need to set your cluster to scale with some target in order for it to work. In my head scaling with request count would be what you want for scale out to happen when a request comes in. I'm currently testing this as well, will add an answer once my deployment completed ;) – Marces Engel Jul 27 '23 at 12:43

1 Answers1

2

Scaling ECS down to zero when not in use is not possible. ECS is designed to run continuously, unlike Lambda functions that can be turned on and off as requests arrive.


However, if your internal users only access the application during known hours (say business hours), then you can use scheduled scaling to scale to zero during specific hours.

You can use put-scheduled-action for that.

aws application-autoscaling put-scheduled-action --service-namespace ecs \
    --schedule "cron(15 12 * * ? *)" \ 
    ...

This AWS Blog post explains it in more detail: https://aws.amazon.com/blogs/containers/optimizing-amazon-elastic-container-service-for-cost-using-scheduled-scaling/

Brian
  • 1,056
  • 9
  • 15
  • 2
    Is the answer outdated ? `If you want your task count to scale to zero when there's no work to be done, set a minimum capacity of 0` https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html – sgargel Jun 20 '23 at 12:11