Skip to the page

Running apps on AWS · core

EC2 vs Lambda vs containers (ECS, Fargate)

EC2 gives you virtual machines you manage, ECS runs containers (on Fargate without managing servers), EKS is managed Kubernetes, and Lambda runs functions per request, so you trade control and steady-state cost against operations work and per-request scaling.

The notes

What you must know

  • EC2: VMs; you patch the OS; scale with Auto Scaling groups behind a load balancer; cheapest at steady load with reserved or savings plans; Graviton (arm64) instances are cheaper per performance.
  • ECS + Fargate: run containers without managing servers; tasks behind an Application Load Balancer; scale on CPU or request count. ECS Express Mode (AWS's suggested replacement for App Runner) sets up a service, ALB and autoscaling in one step.
  • AWS App Runner closed to new customers on 30 April 2026 (existing customers can keep using it, but it gets no new features).
  • EKS: Kubernetes, for teams that need its ecosystem; more operational work.
  • Lambda: per-request functions, scales automatically, max 15 minutes, cold starts, pay per use; great for events and spiky APIs.
  • Typical Node web app: API on ECS Fargate or Lambda, static frontend on S3 + CloudFront, Postgres on RDS, Redis on ElastiCache, files on S3, queues on SQS.

The red pen

Common traps: mistake → fix

  • Mistake: Lambda is always cheapest

    Fix: at steady high traffic, containers or EC2 often cost less.

  • Mistake: Fargate means no capacity planning at all

    Fix: you still choose CPU/memory per task and scaling rules.

Easy to hard

Questions interviewers ask, easy to hard

  1. EC2 vs ECS/Fargate vs Lambda: when do you use each?
  2. How would you deploy an Express API on AWS?
  3. What is Fargate?
  4. How do you scale each option?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview