Comparison
Fargate vs EC2: which compute should your ECS services run on?
ECS asks one question before your first deploy: who owns the servers? Here is how to answer it by what your team will maintain, not by the hourly rate alone.
By Ship It Yourself Editors · Last reviewed
The short answer
Pick Fargate if you run a handful of stateless web services and workers, nobody wants to own servers, and your load moves around. You pay only for what each task asks for, there is nothing to patch, and every task is isolated on its own.
Pick EC2 if you need what Fargate doesn’t offer (GPUs, privileged containers, daemon services, a specific instance family), or your services run steadily enough to fill instances, where packing tasks onto machines you commit to costs less than paying per task. Budget time for AMI updates and capacity scaling, or let AWS manage the instances for you.
“ECS vs Fargate” isn’t really a choice: Fargate is one of the ways ECS runs tasks. The real choice is Fargate or EC2 underneath ECS, and you can mix both in one cluster.
AWS Fargate
Serverless compute for containers. You set CPU and memory per task and AWS finds somewhere to run it. There are no instances in your account to size, patch or scale.
Amazon EC2
Virtual machines in your account that ECS places tasks onto. You pick instance types, keep the AMI and ECS agent current, and scale the fleet, usually through an Auto Scaling group behind a capacity provider.
At a glance
| Fargate | EC2 | |
|---|---|---|
| What it is | Serverless compute for ECS tasks and EKS pods | Virtual machines in your account that ECS or EKS schedules onto |
| What you patch | Nothing; AWS retires and replaces tasks on old platform versions | The AMI, the OS and the ECS agent (or EKS node version) |
| How you size it | CPU and memory per task, from the combinations Fargate supports | Instance types per Auto Scaling group; tasks share the instance |
| How it is billed | Per second for the vCPU and memory each task requests | Per instance for as long as it runs, full or not |
| Discounts | Fargate Spot (ECS only) and Compute Savings Plans | Spot Instances, Reserved Instances and Savings Plans |
| Scaling | Service auto scaling adds tasks; no fleet to scale | Service auto scaling adds tasks; capacity providers scale the instances under them |
| Network modes | awsvpc only: each task gets its own network interface | awsvpc, bridge or host; awsvpc tasks per instance are limited by its network interfaces |
| GPUs | Not supported | GPU instance families supported |
| Privileged containers and daemons | Not supported | Supported (ECS daemon services, DaemonSets on EKS) |
| Image pulls | Every task pulls its image; no cache shared between tasks | Images stay cached on the instance between tasks |
| Isolation | Each task runs in its own isolated environment | Tasks share the instance’s kernel |
Choose Fargate if
- You run a small number of stateless web services, APIs and queue workers.
- Nobody on the team wants to own AMI updates, instance types or a fleet’s scaling.
- Your traffic is spiky, or you run many small services and environments that sit idle much of the day.
- You want each task isolated without thinking about which neighbours it shares a host with.
- Interruptible background work can run on Fargate Spot.
Choose EC2 if
- You need GPUs, privileged containers, host networking or a daemon on every host (log shippers, security agents).
- Your services run steadily enough to keep instances busy, and you can commit to that capacity.
- You need a specific instance family: high memory, fast local storage, a particular processor.
- Large images make startup slow, and a warm cache on the host matters for how fast you scale.
- You run many tasks per host in bridge mode and would hit per-task network interface limits otherwise.
What you actually operate
On Fargate the unit you think about is the task. You set its CPU and memory, its image and its IAM roles, and AWS runs it. There is no instance to log in to, no AMI to rebuild and no agent to upgrade. What you do own is the occasional task retirement: when AWS needs to patch the infrastructure under a Fargate platform version, it notifies you and retires tasks, and an ECS service starts replacements. Make sure your services can lose a task at any time.
On EC2 you own a fleet as well as your tasks. That means choosing instance types, keeping the ECS-optimized AMI (or Bottlerocket) current, draining instances before you replace them, and deciding how many to run. Capacity providers with managed scaling take most of the scaling off you, but the instances are still yours to patch and pay for.
For a team without a dedicated platform engineer that is the core of the decision. Fargate’s work shows up when you change something. EC2’s work shows up on a schedule: every new AMI, and every time the fleet’s shape stops fitting your tasks.
Go deeper: What Your Ops Team Actually Owns When a BYOC PaaS Lands in Your AWS Account
How each is billed
Fargate bills per second for the vCPU and memory a task requests, from the moment it starts pulling its image until it stops, with a short minimum charge. You pay for what you asked for, not what you used, so oversized task definitions cost money on every task. Extra ephemeral storage beyond the included amount is billed too.
EC2 bills per instance for as long as it runs, however full it is. When you pack tasks tightly onto instances that stay busy, and buy Reserved Instances or Savings Plans for that baseline, you usually pay less for the same compute than Fargate charges. When instances sit half empty, or you keep spare room for spikes, that advantage shrinks or reverses, before you count the hours spent keeping the fleet current.
Both have cheaper interruptible capacity: Spot Instances on EC2, Fargate Spot on ECS. Compute Savings Plans cover both. Rates differ by region, operating system and processor (Graviton is priced below x86 on both), so model your own services on the AWS Fargate and Amazon EC2 pricing pages rather than trusting a rule of thumb.
Go deeper: Kubernetes Resource Requests and Limits for Stateless Web Services
Scaling and startup time
On Fargate, scaling a service means starting more tasks; there is no layer of servers to grow first. Every task pulls its image fresh, though, so large images slow every launch. Keep images small, and look at Seekable OCI (SOCI) indexes, which let Fargate start a task before the whole image has downloaded.
On EC2, a new task starts fast when an instance has room and the image is already cached on it. When the fleet is full, the capacity provider has to launch an instance first, and that is slower than starting a Fargate task. Teams often keep some headroom in the fleet to avoid it, which is capacity they pay for while it waits.
Go deeper: Dockerizing a Node.js API for Production
Networking
Fargate tasks always use awsvpc mode: each task gets its own network interface, private IP and security group. That is simple to reason about, and it means every task takes an IP address from your subnets, so size them for the number of tasks you will run at your peak.
On EC2 you can use awsvpc too, and then the number of tasks an instance can hold is limited by how many network interfaces it supports; ENI trunking raises that limit on supported instance types. Bridge and host modes put many tasks behind the instance’s own interface instead, at the cost of per-task security groups.
Go deeper: AWS Account Isolation Requirements Every Engineering Team Should Demand From Their PaaS Vendor
What Fargate can’t run
Fargate has hard limits that decide the question for some workloads. It has no GPUs. It doesn’t run privileged containers or host networking, so tools that need access to the host (some security agents, some observability and network tools) won’t work. ECS daemon services, one task on every instance, need EC2, because on Fargate there is no instance to put them on; run those agents as sidecars instead.
Task size is capped as well, and only certain CPU and memory combinations are allowed; check the table of valid task CPU and memory combinations in the ECS developer guide before you plan a large worker. Persistent storage works on both through Amazon EFS, and ECS can attach an EBS volume to a task on either.
Fargate and EC2 on EKS
The same choice exists on EKS, with sharper limits. EKS runs each Fargate pod on its own isolated node, so DaemonSets don’t run there, and there are no GPUs, no privileged containers and no Fargate Spot. Most production EKS clusters run EC2 nodes, through managed node groups, Karpenter or EKS Auto Mode, and use Fargate for a few isolated workloads, if at all.
If you are deciding between ECS and EKS as well, start there: the orchestrator decides more of your week than the compute under it.
Go deeper: ECS to EKS Migration Without Rebuilding Your Deployment Pipeline
You don’t have to pick one
An ECS cluster can have Fargate, Fargate Spot and EC2 capacity providers at once, and each service chooses its own strategy. A common split: web services on Fargate, interruptible workers on Fargate Spot, and the one GPU or daemon workload on a small EC2 group. Moving a service between them is a change to its capacity provider strategy, not a rewrite, as long as it already uses awsvpc mode.
AWS also offers ECS Managed Instances, where AWS provisions and patches the EC2 instances ECS runs on, for teams that need EC2’s instance choice without owning its upkeep. Check the ECS developer guide for which instance types and features it supports and what it charges on top of the instances.
The third option: a platform on top, in your own account
If you would rather not make these choices service by service, a platform can make them inside your AWS account. Flightcontrol deploys to ECS, on Fargate or EC2, in your account; Porter (this publication’s sponsor) runs Kubernetes on EKS in your account and handles cluster upgrades. Your network, data and bill stay yours either way.
Before you hand it over, write down what the vendor can touch and what happens if you leave.
Go deeper: PaaS Platforms That Deploy Into Your Own Cloud Account
Frequently asked questions
What is the difference between ECS and Fargate?
ECS is the orchestrator: it decides which containers run, how many, and how they are deployed. Fargate is one place ECS can run them, without servers in your account. The other is EC2 instances you manage. EKS can use Fargate too.
Is Fargate more expensive than EC2?
For the same vCPU and memory kept busy all day, EC2 usually costs less, especially with Reserved Instances or Savings Plans. Fargate can cost less when instances would sit partly idle, for spiky or small services, and it removes the hours spent patching and scaling a fleet. Compare your own services on the AWS Fargate and Amazon EC2 pricing pages.
Can I use GPUs on Fargate?
No. GPU workloads on ECS or EKS need EC2 instances (or ECS Managed Instances), so run those services on an EC2 capacity provider or node group and keep the rest on Fargate if you like.
Can I mix Fargate and EC2 in one ECS cluster?
Yes. A cluster can have Fargate, Fargate Spot and EC2 capacity providers together, and each service sets its own capacity provider strategy.
Do I still need to patch anything on Fargate?
Not the hosts: AWS patches the infrastructure and retires tasks on old platform versions, and your service replaces them. You still own your container images, so keep base images and dependencies up to date.
Where to check prices and limits
Rates, quotas and support windows change. Check them at the source before you decide:


