Search code examples
amazon-web-servicesdockeramazon-ecsaws-fargateaws-batch

What is the difference between using AWS Fargate with ECS or with AWS Batch?


AWS Fargate can be used either with AWS Batch or with ECS. In both cases, you provide Fargate with a Docker Image, it executes it, and then stops. Hence, could someone help me understand the advantages/disadvantages of using either of these services?


Solution

  • AWS Batch is an overlay on top of ECS that handles a few things for you that are important for non-interactive tasks. These include (not a complete list):

    1. Queueing up request in a Job Queue. The standard queue is FIFO but you can also create a fair share job queue
    2. Manage the lifecycle of the task/job and automatically resubmit it if it fails for a valid reason such as Spot interruptions.
    3. If you have a lot of requests for the same task, but on different data inputs, you can use array jobs as a single request, and Batch managed services behind the scenes takes care to submit the requests to ECS Fargate without exceeding API limits, etc.

    There may be other benefits that are specific to your workloads but the above should give you a good idea of why Batch over native ECS Fargate for these types of requests.

    As Mark B mentioned, if you are running a stable service, then Batch is not the right solution and you should opt for direct use of ECS Fargate.