Free calculator
Fargate vs Lambda vs EC2 cost calculator
Three ways to run the same workload, priced against each other. The variable that decides it is almost never the hourly rate, it is how much of the hour you actually use.
Set the workload once. The EC2 and Fargate columns price the same vCPU and memory for the same hours; the Lambda column prices the same work as events.
Fargate is sized to match.
Instances, or Fargate tasks.
730 is always on. 220 is roughly weekday working hours.
Lambda column only.
Billed to the millisecond.
Lambda cost scales linearly with this.
EC2 on demand
$60.74/month
$728.88/year · ≈ £47/month
Fargate
$144.16/month
$1,729.92/year · ≈ £112/month
Lambda
$13.50/month
$162.00/year · ≈ £11/month
Fargate is $0.04 per vCPU-hour plus $0.00 per GB-hour. Lambda is $0.00 per GB-second plus $0.20 per million requests, with the free tier deliberately left out because it flatters the comparison. EC2 is on-demand list price; a Savings Plan takes roughly 20% to 30% off the EC2 and Fargate columns and nothing off Lambda requests. arm64 takes about 20% off all three.
The scan reads what you actually run rather than what you planned to run, including the Fargate tasks sized at 4 vCPU that use one.
Estimate the whole billHow to read the result
- →Low duty cycle favours Lambda. Under roughly 25% to 30% busy, per-millisecond billing beats anything that has to stay running. This is why cron jobs, webhooks and infrequent APIs belong on Lambda regardless of how the per-hour rates look.
- →Steady load favours EC2 with a commitment. Once something runs all month, a one-year Compute Savings Plan takes 20% to 30% off EC2 and Fargate. That discount is usually enough to make committed EC2 the cheapest of the three for anything genuinely always-on.
- →Spiky load favours Fargate. Fargate charges per task-second with no instance to keep warm, so you never pay for the headroom an EC2 cluster needs to absorb a spike. This is where the naive per-vCPU comparison misleads people most.
- →Do not forget what surrounds the compute. A container needs a load balancer at about $18 a month and often a NAT gateway at $33. Lambda behind API Gateway pays $1 per million requests. On small workloads these fixed costs are larger than the compute they support.
- →Overprovisioned Fargate is the quiet one. A task defined at 4 vCPU and 8 GB that uses half a core costs more than the EC2 instance it replaced. Fargate removes the instance, not the need to size the thing correctly.
Frequently asked questions
Is Fargate more expensive than EC2?
Per vCPU-hour, yes, by roughly 15% to 25% against on-demand EC2 and considerably more against a Savings Plan. Fargate wins when utilisation is low or spiky, because you pay per task rather than per instance and there is no headroom to fund. A cluster of EC2 instances running at 30% utilisation is usually more expensive in practice than the Fargate tasks that would replace it.
When is Lambda cheaper than a container?
Below roughly 25% to 30% duty cycle, and for spiky traffic. Lambda bills per millisecond with no idle charge, so a function invoked a few million times a month costs a fraction of a container that has to stay warm. Above that, a continuously busy Lambda costs several times what the equivalent Fargate task would.
Does the Lambda free tier change the answer?
For a small workload, completely. The free tier covers 1 million requests and 400,000 GB-seconds a month and does not expire after 12 months. This calculator deliberately leaves it out, because it flatters Lambda in exactly the comparisons where the difference would not matter anyway.
What about Savings Plans?
Compute Savings Plans cover EC2 and Fargate, taking roughly 20% to 30% off both for a one-year no-upfront commitment, and they cover Lambda duration but not Lambda requests. A comparison done at on-demand rates therefore understates how competitive EC2 and Fargate become once you commit.
Does arm64 change the comparison?
It moves all three by a similar amount, roughly 20%, so the ranking usually stays the same. The exception is Lambda, where arm64 functions also tend to run slightly faster, so the duration charge falls as well as the rate.