# Fargate vs EC2 for Amazon ECS

AWS comparisons · Updated 17 November 2026

**Short answer:** Use Fargate by default for ECS services: you pay per task for the vCPU, memory and storage you request and never patch a host. Use EC2 capacity (or ECS Managed Instances) when you need GPUs, privileged containers, specific instance types, or when steady, well-packed workloads make paying per instance cheaper than paying per task.

## Fargate vs EC2 side by side

| Factor | Fargate | EC2 capacity |
|---|---|---|
| You pay for | vCPU, memory and ephemeral storage requested per task, per second, one-minute minimum (Linux) | The instances, whether tasks fill them or not |
| Host management | None | AMIs, patching, agent updates, scaling the Auto Scaling group |
| Task sizes | Fixed combinations from 0.25 vCPU / 512 MiB up to 16 vCPU / 120 GB, plus 32 vCPU options | Anything that fits the instance |
| GPU, privileged, custom kernels | Not supported (`gpu` and `privileged` are invalid) | Supported |
| Networking | `awsvpc` only: one ENI per task | `awsvpc`, `bridge` or `host` |
| Storage | 20 GB ephemeral included, up to 200 GB; EFS and EBS volumes | Instance disks, EBS, EFS, Docker volumes |
| Spot | Fargate Spot capacity provider, two-minute warning | EC2 Spot through Auto Scaling groups |
| Commitment discounts | Compute Savings Plans | Compute or EC2 Instance Savings Plans, Reserved Instances |

## When Fargate wins

- Services that scale up and down. You stop paying the moment a task stops; there is no half-empty instance waiting for the scale-in cooldown.
- Small teams. Not owning AMIs, the ECS agent or instance draining removes a whole class of 3 a.m. pages.
- Isolation. Each task gets its own kernel boundary and ENI, so security groups apply per task.
- Batch and scheduled jobs that run for minutes, where per-second billing beats keeping instances warm.

Fargate Spot runs interruption-tolerant tasks at a discount; ECS sends `SIGTERM` with a two-minute warning, so handle the signal and drain work.

## When EC2 wins

- You need GPUs, `privileged` mode, extra Linux capabilities beyond `CAP_SYS_PTRACE`, or host networking.
- Steady, predictable services you can bin-pack densely. If tasks fill instances well, paying per instance is often cheaper than Fargate's per-task rate. Check your real utilisation before assuming this.
- You want a specific instance family, local NVMe, or a capacity reservation.
- You run daemon tasks (log shippers, agents) on every host; the daemon scheduling strategy needs EC2.

A middle option now exists: ECS Managed Instances. AWS provisions, patches and scales the EC2 instances for you and charges a management fee on top of the instance price, while you keep instance-type choice and GPUs.

## Switching capacity type

Use capacity providers rather than launch types. A service created with the Fargate launch type cannot be updated straight to the EC2 launch type, but it can move to an Auto Scaling group capacity provider (and back) with `UpdateService`, provided the task definition lists the target in `requiresCompatibilities`.

Before moving to Fargate, check the task definition for parameters Fargate rejects (`links`, `dockerVolumeConfiguration`, `privileged`, `gpu`) and pick a valid CPU and memory pair. A mixed strategy is also possible: a Fargate base with Fargate Spot on top for burst.

## Common wrong reasons

- **"EC2 is always cheaper."** Only if you keep instances full. Idle headroom, the scale-in lag and the hours spent patching often erase the gap.
- **"Fargate is slow to start."** Image size dominates start time on both. Smaller images and a nearby registry help more than switching capacity.
- **"Fargate means no networking to plan."** Every task takes an IP address from your subnet. Large services need large subnets.

## Questions

### Is Fargate more expensive than EC2?

Per vCPU-hour, Fargate usually costs more than a fully used instance, but you pay only for what each task requests and only while it runs. For spiky or small workloads Fargate is often cheaper overall.

### Can one ECS cluster use both Fargate and EC2?

Yes. A cluster can have Fargate, Fargate Spot, Auto Scaling group and Managed Instances capacity providers, although one capacity provider strategy cannot mix the types.

### Does Fargate support GPUs?

No. The gpu task definition parameter is not valid on Fargate. Use EC2 capacity or ECS Managed Instances for GPU workloads.

## When this happens away from your desk

On Fargate there is no host to log in to when a task dies, so the stopped reason and the container logs are all you have; on EC2 you may also be chasing a full disk or a stuck agent. CloudConsole is being built to show ECS alarms, logs and resources on a phone with production guardrails.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Amazon ECS launch types and capacity providers](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/capacity-launch-type-comparison.html)
- [Amazon ECS task definition differences for Fargate](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/fargate-tasks-services.html)
- [AWS Fargate pricing](https://aws.amazon.com/fargate/pricing/)

## Related

- [ECS vs EKS](https://cloudconsole.dev/vs/ecs-vs-eks)
- [Lambda vs Fargate](https://cloudconsole.dev/vs/lambda-vs-fargate)
- [On-Demand vs Spot Instances](https://cloudconsole.dev/vs/on-demand-vs-spot)
- [Graviton vs x86 on AWS](https://cloudconsole.dev/vs/graviton-vs-x86)
- [service was unable to place a task because no container instance met all of its requirements](https://cloudconsole.dev/errors/ecs-unable-to-place-task)
- [ResourceInitializationError: unable to pull secrets or registry auth](https://cloudconsole.dev/errors/ecs-resourceinitializationerror)

---

Source: https://cloudconsole.dev/vs/fargate-vs-ec2

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
