Skip to content
>_higan
This post is currently only available in the original language (English).

ECS on EC2 vs ECS on Fargate: What Should You Choose?

A practical breakdown of how ECS's two launch types actually differ — not just on paper, but in the 2am-pager kind of way.

Every team running containers on AWS eventually hits this fork in the road. You've picked ECS as your orchestrator — good call, less YAML in your life — and now the console asks you: EC2 or Fargate?

Most articles answer this with a feature comparison table and call it a day. That's not really the question, though. The real question is: who do you want holding the pager when a node runs out of memory at 2am — you, or AWS?

How They Work

ECS itself doesn't change between the two. The control plane — task definitions, services, scheduling logic — is identical either way. What changes is the compute underneath it, and that's the whole ballgame.

With the EC2 launch type, you own a fleet of EC2 instances. Each one runs the ECS container agent, registers itself with your cluster, and ECS schedules tasks onto whichever instance has room. You're doing bin-packing across real servers. You pick the instance types, you manage the AMI, you patch the OS, you size the Auto Scaling Group so there's always enough headroom for the next deployment.

With Fargate, that entire layer disappears. You describe a task — this many vCPUs, this much memory, this image — and AWS hands it a sandboxed slice of compute that exists for exactly as long as the task runs. No instances to register, no capacity to pre-provision, no agent to babysit.

Here's the way I'd put it:

ECS is the brain, Fargate is a serverless body. You can run ECS with or without servers.

The scheduling intelligence is constant. What you're really choosing is whether that brain gets to control a body it owns, or rents one on demand.

ECS Container Instance vs Fargate Source: cloudonaut.io — ECS vs. Fargate: What's the difference?

Cost and Responsibility

The tradeoff isn't really about which is "cheaper" — it's about where the money and the toil go.

EC2Fargate
Billing unitPer EC2 instance (running or idle)Per task, per second (vCPU + memory)
Cost leversSpot, Reserved, Savings Plans, bin-packingFargate Spot (up to −70%), Compute Savings Plans
Your responsibilityInstances, AMIs, patching, scaling, agent versionsTask definition only — host OS and capacity are AWS's problem
RiskFragmented capacity, stranded resources, placement failuresNo idle waste, but no density gains either

EC2 wins on raw compute cost when your instances are well-utilized — but the price you're really paying is operational. Patch cadence, scaling policies, debugging why a task won't place because an instance is fragmented across reservations... that toil adds up.

Fargate makes your responsibility stop at the task definition. The cost premium is real, but it's smaller than it looks once you factor in Fargate Spot for interrupt-tolerant workloads and Compute Savings Plans for stable ones.

EC2 shifts cost savings to you in exchange for operational ownership. Fargate shifts that ownership to AWS in exchange for a premium.

Making the Right Choice

There isn't a universally correct answer here, and anyone who tells you otherwise is selling something. It comes down to your traffic shape, your team size, and how much infrastructure babysitting you're willing to sign up for.

Choose Fargate if:

  • Your team is small and infra ops isn't where you want to spend your hours
  • Traffic is spiky or unpredictable, and pre-provisioning capacity feels like guesswork
  • You're running a lot of distinct, low-density workloads (batch jobs, cron-style tasks, low-traffic services) where instance packing doesn't pay off anyway
  • You want strong workload isolation by default — each Fargate task runs in its own sandbox with no shared host between tasks
  • Shipping speed matters more right now than shaving the compute bill

Choose EC2 if:

  • You're running at a scale where instance-level cost optimization (Spot, Reserved, Savings Plans) meaningfully moves the needle
  • You need specific hardware — GPUs, high-memory instances, specialized network throughput — that Fargate doesn't expose
  • You want daemon-style processes running once per host (log shippers, monitoring agents) instead of duplicated per task
  • Your workloads are dense and steady enough that you can bin-pack efficiently and actually use the capacity you pay for
  • You have (or want) the operational maturity to own patching, AMIs, and capacity planning

Which Model Fits Your Project?

For most new projects, start with Fargate. The operational simplicity means your team ships faster early on, and you can always migrate high-density workloads to EC2 later when the cost math actually justifies it.

For teams at meaningful scale with stable, predictable workloads, EC2 is worth evaluating seriously — especially if you already have strong infrastructure practices and want the density gains from running multiple services on shared instances.

In practice, plenty of real production setups don't pick one and stick with it forever. They run Fargate for the unpredictable, spiky services and EC2 for the steady, high-density workhorses, using capacity providers to let ECS split traffic between both seamlessly. The brain doesn't care which body it's driving.

The important part is understanding what you're trading away when you choose one over the other. EC2 and Fargate aren't opposites — they're two points on the same spectrum between full infrastructure ownership and full infrastructure abstraction.

ECS stays the same. The real decision is who manages the compute underneath it: you, or AWS.

Share: