To make it better, you can remove the use of ECS and use aws Batch instead, and aws batch will create an ECS in the background whenever it gets triggered and afterwards it will be automatically cleaned. Using AWS Batch can simplify your setup even further, especially if you're looking to reduce the operational overhead of managing ECS tasks. And you can configure it also to use spot instances. Configure AWS Batch to limit the max parallelism to 5 (or any desired number). And Jobs automatically scale up and down based on the queue size.