rix
rix

Reputation: 10642

ECS instance scaling to/from 0

I have a service which runs 1 task. The task takes 2 hours to run and runs daily. My ideal scenario would be this:

  1. I update my service to from 0 desired tasks to 1 desired task
  2. ECS sees that in order to run the service I need an EC2 Instance. It therefore spins up an instance to run the task.
  3. When the task finishes it updates the service to 0 desired tasks.
  4. ECS sees that I don't need the instance to run 0 tasks and turns it off

Using the ECS admin it looks like this is possible but in reality, when I scale up my service from 0->1 task, it just complains there is no instances to run the task, rather than autoscaling an instance. I set the auto scale policies of the cluster to min=0, desired=1, max=1 however it makes no difference.

I'd like to know if my ideal scenario is indeed possible, or if there is a better way to achieve this goal.

Thanks in advance,

Upvotes: 2

Views: 3307

Answers (1)

Mech
Mech

Reputation: 1504

Unfortunately point 2 and 4 is not true for ECS (EC2 launch type). By default it will neither launch the EC2 instance nor terminate the instance.

Actually FARGATE is more costlier than ECS(EC2 lauch type). But for your use case FARGATE will be much more cheaper [1] compare to ECS(EC2 lauch type).

But again FARGATE would not be the best option. According to your use case best option would be AWS Batch [2]. Batch uses the ECS as a back end and main advantage using batch is it will also perform the step 2 and step 4 mentioned in your use case.

[1] https://aws.amazon.com/fargate/pricing/

[2] https://docs.aws.amazon.com/batch/latest/userguide/what-is-batch.html

Upvotes: 2

Related Questions