AWS fargate running 24*7

Viewed 890

we have an application which runs for 15 mins * 3 times a day. We dont want container to be running always (24*7). Once applicaiton finish, container should stop. i dont think we can achieve this in AWS Fargate

Will you please recommend any such container services in AWS?

3 Answers

From your description, you need to setup an ECS Scheduled Task, which will start the Fargate container at certain times of day, the container will stop once the process exits, and it will not be restarted until the next scheduled time.

Alternatively, you can some other process outside of ECS, such as a Lambda function, call the ECS RunTask API to accomplish the same thing.

In the above scenario, you will only be billed for the time the Fargate task is running.


This contrasts with an ECS Service, which typically keeps one or more tasks running 24/7. Although you can setup ECS Service auto-scaling to scale down to 0 tasks, which is another option you might pursue.

What you want is completely achievable, a task will stop once it's finished, only a service will always stay up and running.

Another solution would be to use an AWS Lambda, as an AWS lambda can run up to 15 minutes. You can also specify a docker image to run your AWS lambda in.

For what you need to achieve (Once applicaiton finish, container should stop.), there is two approaches:

1- if your task takes less than or equal to 15 minutes, you could use AWS ECR to host your container, then trigger it using AWS lambda which has a timeout of 15 minutes.

1.1- For pricing, you will be charged based on the RAM you choose and this will automatically increase the vCPU that the lambda will use, and also the running time of the lambda.

2- if your task takes more than 15 minutes, you could use AWS ECS with AWS Fargate, you can refer back to @Mark B answers.

2.1- for pricing, you will be charged based on the number of tasks that you run, the average time your task needs to finish and the resources you tell Fargate to provision on your behalf.

For more accurate price calculations, please refer to aws pricing calculator

Related