ECS vs Lambda vs App Runner: which to use in 2025
Quick decision matrix
| Workload | Best fit |
|---|---|
| HTTP API, always-on, predictable | ECS Fargate |
| Event-driven, spiky, scale-to-zero | Lambda |
| HTTP API, minimal ops overhead | App Runner |
| WebSocket / long-lived connections | ECS Fargate |
| Scheduled batch | Lambda + EventBridge |
ECS Fargate
resource "aws_ecs_service" "api" {
name = "payment-api"; cluster = aws_ecs_cluster.main.id
task_definition = aws_ecs_task_definition.api.arn
desired_count = 2; launch_type = "FARGATE"
network_configuration {
subnets = var.private_subnet_ids; assign_public_ip = false
security_groups = [aws_security_group.api.id]
}
}
Watch out: idle containers still cost money (billed per-second).
App Runner
resource "aws_apprunner_service" "api" {
service_name = "user-api"
source_configuration {
image_repository {
image_configuration { port = "8080" }
image_identifier = "${aws_ecr_repository.api.repository_url}:latest"
image_repository_type = "ECR"
}
auto_deployments_enabled = true
}
}
Watch out: less networking control than ECS.
Cost comparison (1M req/month, 100ms avg, 512MB)
Lambda: ~$0.41/month
App Runner: ~$5-8/month
ECS Fargate: ~$9.27/month (24/7)
Lambda wins at spiky/low volume. ECS wins at steady-state high volume.
My recommendation
- Small team, ops is a constraint: App Runner
- Need networking control or persistent connections: ECS Fargate
- Event-driven processing: Lambda — genuinely the right tool
All three are supported in Step2Dev.
What compute pattern has worked best for your team and why?
Top comments (0)