"In ECS, a task and a service are the same thing." They aren't, and mixing them up is how a container crashes at night and nobody restarts it. A task runs and can stop. A service keeps tasks running.
What Amazon ECS does
Amazon Elastic Container Service (ECS) is AWS's fully managed container orchestrator. It decides where each container runs, starts it and watches it. There's no control plane to install, and on Fargate or EC2 there's no separate ECS fee: you pay for the compute underneath.
Tasks and services run inside a cluster, a logical group.
Task definitions: the blueprint
A task definition is a JSON document that describes one or more containers: the container image, how much CPU and memory they get, which ports they expose, environment variables, log settings and the IAM role the task uses. Every change creates a new revision, so you can roll back to an earlier one.
A common mistake is treating the task definition as the running app. It isn't. It's a recipe; nothing runs until you start a task or create a service from it.
Tasks: run once, then stop
A task is one running copy of a task definition. Started directly with RunTask, it does its work and stops: right for batch jobs, migrations or a nightly report. If a standalone task crashes, ECS doesn't start another one for you. That's by design.
Services: keep it running
A service keeps a desired number of tasks running at the same time. Ask for three, and if one fails or stops, the ECS service scheduler launches a replacement until you're back at three. It also replaces tasks that fail a container health check or a load balancer health check.
Services add the things a long-running app needs:
- Load balancing: put an Application Load Balancer or Network Load Balancer in front, and traffic is spread across the tasks.
- Service auto scaling: the desired count goes up when demand rises and down when it falls.
- Deployments: when you point the service at a new task definition revision, ECS rolls the new version out and retires the old tasks.
Rule of thumb: web apps and APIs are services; jobs that finish are tasks.
Where tasks run
ECS separates what runs from where it runs. The capacity options are:
- AWS Fargate: serverless. You set CPU and memory per task and never see a server.
- Amazon EC2 instances: you choose the instance types and manage the capacity yourself. See EC2 instance types.
- ECS Managed Instances: EC2 instances where AWS handles provisioning, patching and scaling, with access to specialised instance types such as GPUs. It adds a management fee per instance on top of the EC2 price.
- ECS Anywhere: your own servers or VMs on premises, registered to a cluster.
For the simplest web workload there's also ECS Express Mode (launched November 2025), which creates the service, load balancer, auto scaling and a URL from a container image in one step.
Where AI fits
A common AI pattern is an inference API: a container that loads a model and answers requests. On ECS that's a service behind a load balancer, so failed tasks are replaced and auto scaling follows demand.
The catch is hardware. Fargate doesn't support GPUs, so a GPU model needs EC2 instances or ECS Managed Instances with GPU instance types. If your API only calls a hosted model, such as one on Amazon Bedrock, it doesn't need a GPU and Fargate works fine.
Quick recap
- The task definition is the blueprint: image, CPU, memory, ports.
- A task is one running copy; it runs and stops.
- A service keeps a desired number of tasks running, behind a load balancer, with auto scaling.
- Tasks run on Fargate, EC2 or ECS Managed Instances; GPUs need EC2 or Managed Instances.