EC2 vs ECS vs Lambda Cost
Compute cost comparison.
Overview
EC2, ECS, and Lambda each fit different workload shapes. Matching the workload to the service produces real cost-performance; mixing them produces a bill that looks like a copy of the AWS console.
- Workload-driven choice. Stable, containerised, and event-driven workloads each select different services.
- EC2: max control. Long-running stable workloads with custom kernel needs or steady traffic. Reserved-instance pricing rewards predictability.
- ECS or Fargate: containerised. Mid-volume containerised services. Fargate removes the cluster-management tax; ECS-on-EC2 wins on cost density.
- Lambda: event-driven. Sporadic, event-triggered work. Per-invocation billing matches variable load directly.
The approach
Three habits produce defensible compute choices: pick by workload not by trend, project cost honestly, and document the choice so the next renewal does not relitigate it.
- Workload-driven evaluation. Match the service to the workload shape, not the latest re:Invent talk.
- EC2 for stable workloads. Long-running steady traffic earns the reserved-instance discount and maximises control.
- ECS or Fargate for containerised mid-volume. Standard container shapes; Fargate when the team wants no cluster ops.
- Lambda for event-driven. Sporadic invocations where the per-invocation cost wins. Long-running Lambdas are a code smell.
Why this compounds
Each correctly-matched workload produces ongoing cost and operational benefit. The team learns the compute trade-offs through repeated decisions; new services ship in the right home from day one.
- Cost efficiency. Right service for the workload keeps the bill matched to actual usage.
- Operational fit. Right service matches what the team can operate. Lambdas the team cannot debug are worse than EC2.
- Engineering culture. Workload-driven decisions replace tribal preference. New services justify their compute choice in design review.
- Year-one investment, year-two habit. The first decision takes effort. By the fifth service, the choice is reflexive and the bill matches the design.