Containers vs serverless: the cost crossover at 2-3M requests/day
Lambda wins for sporadic and event-driven workloads. Containers win for steady high-volume traffic. The crossover is around 2-3M requests/day for typical APIs. Here's the math, the workload archetypes, and a decision framework.
Quick answer
Lambda wins on cost for sporadic workloads (under ~1-2M requests/day per function), event-driven patterns, and APIs with idle time. Containers (ECS/EKS) win for steady high-volume traffic, long-running processes, and stateful workloads. Fargate and serverless-container services (Cloud Run, Container Apps) fill the middle. The break-even depends on request rate, duration, and memory.
The serverless-vs-containers cost debate is one of the most common architecture decisions, and it's also one of the most often-wrong. Both camps make absolute claims ("Lambda is always cheaper at scale" / "Containers are always cheaper") that don't survive contact with actual workload math.
This post walks through the cost models, the break-even points, and a decision framework for picking the right one for a specific workload.
The cost models
Lambda
- $0.20 per million requests
- $0.0000166667 per GB-second of compute time
- Free tier: 1M requests + 400K GB-seconds/month
- Provisioned Concurrency: $0.0000041667/GB-second (always-on)
- No storage cost for code
ECS on EC2
- EC2 instance hours (e.g., m6i.large: $0.0832/hour, $60.74/month)
- EBS volume for the host
- $0 for ECS itself (control plane is free)
- ECR storage: $0.10/GB-month
- Load balancer: $16.20/month ALB minimum
ECS on Fargate
- $0.04048/vCPU-hour
- $0.004445/GB-hour
- Per-second billing (minimum 1 minute)
- ECR storage + ALB same as EC2
EKS
- $0.10/hour control plane fee ($73/month per cluster)
- Plus EC2 or Fargate node costs
- Plus ALB/NLB
Cloud Run (GCP)
- $0.00002400/vCPU-second
- $0.00000250/GB-second
- $0.40 per million requests
- Free tier: 180K vCPU-seconds + 360K GB-seconds + 2M requests/month
The workload archetypes
Archetype 1: Sporadic API (10K req/day)
Internal tool API, low-traffic SaaS, side project. Roughly 7 requests per minute average, 100ms response time, 256 MB memory.
Lambda math:
- 10K req/day × 30 = 300K req/month
- Request cost: 300K × $0.0000002 = $0.06
- Compute: 300K × 0.1s × 0.25 GB × $0.0000166667 = $0.13
- Total: $0.19/month (essentially free, covered by free tier)
ECS on Fargate math (1 task, 0.25 vCPU, 0.5 GB):
- vCPU: 0.25 × $0.04048 × 730 = $7.39
- Memory: 0.5 × $0.004445 × 730 = $1.62
- ALB: $16.20
- Total: $25.21/month
Lambda wins by 100x for this workload. Don't run sporadic APIs on containers if Lambda will work.
Archetype 2: Steady API (5M req/day)
Production API behind a load balancer. 60 req/sec average, 200ms response time, 512 MB memory.
Lambda math:
- 5M × 30 = 150M req/month
- Request cost: 150M × $0.0000002 = $30
- Compute: 150M × 0.2s × 0.5 GB × $0.0000166667 = $250
- Total: $280/month
ECS on EC2 math (m6i.large always running):
- EC2: $60.74/month (single m6i.large handles this easily)
- ALB: $16.20
- EBS: $8 (100 GB gp3)
- Total: $84.94/month
Containers win by 3x for steady high-volume APIs. For always-busy workloads, the per-request fees dominate Lambda's cost.
Archetype 3: Event-driven processor
Process S3 events, SQS messages, or Kinesis records. Bursty, idle most of the time, occasional peaks.
Lambda is purpose-built for this archetype. Pay only when events arrive. No idle cost. Native integrations with S3/SQS/Kinesis.
Containers for this workload need either an always-on consumer (paying for idle) or autoscaling that's slower to respond than Lambda. Almost always Lambda wins for event-driven.
Archetype 4: Long-running batch
ML training, data processing, video encoding. Jobs run 30 minutes to multiple hours.
Lambda has a 15-minute execution limit. Hard stop for jobs longer than that. ECS/EKS/Batch with Spot instances is the right answer for long-running batch. Often 80%+ cheaper than on-demand EC2 due to Spot.
The middle ground: serverless containers
Fargate, Cloud Run, and Azure Container Apps occupy the middle. They:
- Bill per-second (Fargate, Container Apps) or per-request (Cloud Run)
- Don't require node management
- Scale to zero (Cloud Run, Container Apps consumption)
- Support container images (unlike Lambda which has stricter packaging)
Cost-wise, serverless containers fall between Lambda and traditional containers. For workloads that would be cheaper on Lambda (low volume) but need container features (long-running, custom runtimes, large images), serverless containers fit.
The break-even calculator (rough)
For a typical API with 200ms response time, 512 MB memory, no Provisioned Concurrency:
| Daily Requests | Lambda | ECS/EC2 | Winner |
|---|---|---|---|
| 10K | $0.19 | $85 | Lambda (450x) |
| 100K | $2 | $85 | Lambda (42x) |
| 1M | $20 | $85 | Lambda (4x) |
| 5M | $280 | $85 | ECS (3x) |
| 20M | $1,200 | $200 | ECS (6x) |
The crossover is around 2-3M requests/day. Below that, Lambda wins. Above that, containers win.
What changes the break-even
Response time
Lambda bills per GB-second. A 1000ms response time at 1 GB memory costs 10x what a 100ms response at 1 GB costs. Long responses shift the break-even lower (containers win sooner).
Memory allocation
More memory = more cost per invocation on Lambda. A 2 GB Lambda function is 2x more expensive than 1 GB at the same duration. Containers don't have this per-request memory cost.
Provisioned Concurrency
If you need Provisioned Concurrency to avoid cold starts, you're paying for idle Lambda capacity. The cost becomes closer to containers without the ergonomics. Often the right move is to migrate to containers at this point.
Spot instances
If your container workload can tolerate Spot interruptions, EC2 Spot at 60-90% discount makes containers even cheaper. Lambda has no equivalent.
Hidden costs to remember
- API Gateway: $1/million HTTP API requests on top of Lambda. For 100M req/month, that's $100 added.
- CloudWatch Logs: $0.50/GB ingested. Verbose Lambda logs add up fast. Filter at the source.
- NAT Gateway: Lambda functions in VPC need NAT. $32/month + $0.045/GB.
- X-Ray: $5/M traces. Optional but commonly used.
- Container registry: ECR/GCR storage at $0.10/GB-month.
FAQ
What's the request volume break-even between Lambda and containers?
Roughly 1-2M requests/day. Below that, Lambda's pay-per-invocation model is cheaper than running containers 24/7. Above 5-10M requests/day, containers (ECS/EKS) typically win because Lambda's per-request fees and per-GB-second compute fees add up. The exact break-even depends on request duration and memory allocation.
Are Lambda cold starts a cost concern?
For most workloads, no — cold starts are a latency issue, not a cost issue. The exception is Provisioned Concurrency, which bills $0.000004167/GB-second to keep instances warm. For latency-sensitive APIs with low traffic, Provisioned Concurrency adds cost without saving compute. Cold start cost itself (the extra ms of init time) is negligible.
Does Fargate offer the best of both worlds?
Fargate is serverless containers — you pay per vCPU-hour and GB-hour without managing nodes. Generally more expensive than EC2-backed ECS/EKS for sustained workloads (40-50% premium), but eliminates the overhead of node management. Right for moderate-volume containers without dedicated DevOps capacity.
How do GCP Cloud Run and Azure Container Apps compare?
Both are 'serverless containers' similar in concept to Fargate but priced per-request like Lambda. Cloud Run bills per-request + per-vCPU-second + per-GB-second. Azure Container Apps has consumption + dedicated plans. For event-driven workloads, both are competitive with Lambda. For steady traffic, traditional containers are usually cheaper.
What about cold storage of containers vs Lambda?
Container images live in ECR/GCR/ACR at storage rates ($0.10/GB-month typical). A 500MB image = $0.05/month. Lambda functions store at $0/month — no storage charge for the code itself. For workloads with many large container images, storage adds up. For Lambda, the code size is included in invocation fees.
Should I migrate from Lambda to containers as I scale?
Sometimes. The signals: monthly Lambda bill exceeds $500-1000 and is growing, single function has steady high request volume (10M+/day), Provisioned Concurrency starts to dominate. The migration is non-trivial (rewriting handlers, managing the runtime, adding a load balancer). Don't migrate just because containers feel more 'real' — do it when the math says so.
Summary
Lambda for sporadic, event-driven, and short workloads. Containers for steady, high-volume, long-running, or stateful workloads. The crossover is around 2-3M requests/day for typical APIs. Above that, containers win on cost. Below, Lambda wins. Pick based on actual request volume, not architectural preference.
For deeper Lambda cost analysis, see estimating AWS Lambda costs from Terraform. For ECS vs EKS specifically, see EKS vs ECS total cost comparison.
Share this post
Try C3X on your own Terraform
Free and open source. No API key required. One command to install, one command to estimate.