🎉 DevOps Interview Prep Bundle is live — 1000+ Q&A across 20 topicsGet it →
All Articles

AWS Fargate vs EKS vs Lambda: Which for Running Containers in 2026?

AWS Fargate, EKS (on EC2), and Lambda containers compared for 2026 — cold start time, cost at different scales, operational overhead, and which to pick for your workload pattern.

Shubham4 min read
Share:Tweet

"Just run it on Kubernetes" is not always the right answer, even inside AWS. Fargate, EKS on EC2, and Lambda containers solve overlapping problems with very different operational and cost profiles — here is an honest comparison.

Quick Comparison

Fargate (ECS or EKS)EKS on EC2Lambda (container image)
Operational overheadLow — no node managementHigh — you manage nodes, patching, scalingLowest — fully managed
Cold startNone (long-running tasks)None (long-running pods)Seconds, unless provisioned concurrency
Max runtimeUnlimitedUnlimited15 minutes hard limit
Cost at steady high loadHigher per-vCPU than EC2Lowest per-vCPU (especially with Spot/Savings Plans)Can spike expensive at sustained high invocation rates
Cost at bursty/idle loadPay only for running tasksPay for nodes even when idlePay only per invocation — best for spiky traffic
Kubernetes API accessYes (EKS on Fargate) or no (ECS Fargate)FullNo

Fargate

Fargate removes node management entirely — you define a task/pod spec and AWS runs it on infrastructure you never see, whether through ECS or as an EKS Fargate profile.

yaml
# EKS Fargate profile — pods matching this selector run serverless
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
fargateProfiles:
  - name: fp-default
    selectors:
      - namespace: default
        labels:
          compute-type: fargate

Fargate strengths:

  • Zero node patching, zero capacity planning, zero cluster-autoscaler tuning
  • Strong isolation — each task/pod gets its own dedicated kernel, not shared with noisy neighbors
  • Scales cleanly for variable workloads without pre-provisioning nodes

Fargate weaknesses:

  • Meaningfully more expensive per vCPU/GB than EC2, especially at sustained high utilization
  • No DaemonSets, no host networking, no privileged pods — some Kubernetes patterns just don't work on Fargate
  • Slower pod startup than an already-warm EC2 node with capacity available

When to use Fargate: Variable or moderate-scale workloads where the ops savings outweigh the per-unit cost premium, or workloads needing strong per-task isolation.

EKS on EC2

Running EKS with EC2 (or Karpenter-managed) node groups gives you full Kubernetes with the cost efficiency of owning the underlying compute.

yaml
# Karpenter NodePool — cheapest path to EKS-on-EC2 cost efficiency
apiVersion: karpenter.sh/v1
kind: NodePool
spec:
  template:
    spec:
      requirements:
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["spot", "on-demand"]
      nodeClassRef:
        name: default

EKS on EC2 strengths:

  • Lowest cost per vCPU/GB, especially combined with Spot instances and Savings Plans
  • Full Kubernetes feature set — DaemonSets, host networking, privileged pods, custom device plugins (GPUs)
  • Karpenter has made node provisioning genuinely painless — most of the historical "EC2 is more ops work" argument has narrowed significantly

EKS on EC2 weaknesses:

  • Still real operational surface: node AMI updates, security patching cadence, node draining during upgrades
  • Under-provisioned clusters have real capacity risk during traffic spikes that Fargate/Lambda don't have
  • Multi-tenant node isolation is weaker than Fargate's dedicated-kernel model unless you invest in additional isolation

When to use EKS on EC2: Steady, predictable, high-scale workloads where per-unit cost matters, or workloads needing Kubernetes features Fargate doesn't support.

Lambda (Container Images)

Lambda supports container images up to 10GB, letting you package existing Docker workflows into a fully serverless, pay-per-invocation model.

dockerfile
FROM public.ecr.aws/lambda/python:3.13
COPY app.py requirements.txt ./
RUN pip install -r requirements.txt
CMD ["app.handler"]

Lambda strengths:

  • True pay-per-invocation — genuinely the cheapest option for spiky, low-average-utilization workloads
  • Zero infrastructure to manage, ever — no cluster, no tasks, no nodes
  • Scales to zero and back up automatically without any configuration

Lambda weaknesses:

  • 15-minute hard execution limit rules out long-running jobs entirely
  • Cold starts are real, especially for larger container images — provisioned concurrency mitigates this but adds cost back
  • Cost curve inverts at high sustained invocation rates — a busy Lambda function can cost more than the equivalent Fargate task doing the same work continuously

When to use Lambda: Event-driven, bursty, or infrequent workloads where "always-on" compute would sit idle most of the time.

The Honest Verdict

Predictable, high-scale, steady workloads: EKS on EC2 with Karpenter. The cost advantage compounds fast at scale, and Karpenter has closed most of the operational gap.

Variable workloads, want to skip node management entirely: Fargate. Pay the per-unit premium for genuinely zero ops.

Spiky, event-driven, or infrequent: Lambda. Nothing beats true pay-per-invocation for workloads that are idle most of the time.

Many production architectures at scale actually run all three — Lambda for event handlers, Fargate for the moderate-traffic API tier, EKS on EC2 for the steady-state high-throughput backend — matched to each workload's actual traffic shape rather than picking one compute model for everything.


More AWS compute comparisons? Read our AWS EKS vs self-managed Kubernetes comparison and AWS Lambda vs Kubernetes Jobs for batch processing.

🔧

Today I Fixed

Short real fixes from production — posted daily

Browse fixes
Newsletter

Stay ahead of the curve

Get the latest DevOps, Kubernetes, AWS, and AI/ML guides delivered straight to your inbox. No spam — just practical engineering content.

Related Articles

Comments