How to make AWS Stepfunctions/ECS schedule tasks only when resources are available

Viewed 14

I am using ECS/EC2 to run Stepfunction (Standard type) tasks

I am using an API to trigger the StepFunction execution, So sometimes I have a peek more thyan the capacity of the ECS cluster, So I frequently get errors like this:

[{"Arn":"arn:aws:ecs:us-east-1:432214534264:container-instance/192a09715eea48828b798600b5c67532","Reason":"RESOURCE:GPU"}] (Service: AmazonECS; Status Code: 400; Error Code: AmazonECS.Unknown; Request ID: d33c3afa-d158-45f4-83f4-2567efb53017; Proxy: null)

Which means I do not have enough GPU (Sometimes MEMORY) to run more tasks.

So, How to configure the StepFunction and/or the ECS cluster to only schedule tasks if its resources are available.

I tried PlacementConstraints and PlacementStrategies, but they are fit for this, as these are guides to distribute tasks when resources are enough, not to pause new task creation till resources are available

Thanks

0 Answers
Related