Search code examples
amazon-web-servicesamazon-ecsaws-fargate

AWS Fargate has max run time of 120 seconds?


I thought one reason to use AWS Fargate over Lambda is because it has not its limits, like max runtime (and others). However, today I discovered that the parameterstopTimeout which is by default set to 30s while its maximum is 120s. See AWS documentation for Task definition parameters.

Am I misunderstanding this stopTimeout parameter? I would like to run a task that might take 10-20 min. If I do indeed misunderstand something, what does this parameter mean?


Solution

  • If I do indeed misunderstand something, what does this parameter mean?

    Yes, you are misunderstand the parameter. Your task can run for as long as you want. However, sometimes you will want to stop it, or autoscaling group will want to do it due to health check failure, it can get stuck. The stopTimeout determines how long ECS will wait before forcefully killing the task if it's stuck, and does not stop on its own.

    The ECS Task lifecycle explains it more into detail:

    STOPPING

    This is a transition state where Amazon ECS is waiting on the container agent to take further action.

    For Linux containers, the container agent will send the SIGTERM signal to notify the application needs to finish and shut down, and then the sends a SIGKILL after waiting the StopTimeout duration set in the task definition.