Skip to the page

Scaling and running in production · mid

Serverless vs containers

Serverless functions (AWS Lambda, Vercel functions) run your code per request with no servers to manage and scale to zero, but bring cold starts, time limits and connection problems, while containers (ECS/Fargate, Kubernetes) run long-lived processes you size and scale yourself.

The notes

What you must know

  • Lambda: pay per request and duration, scales automatically, max 15 minutes per invocation, cold starts when a new instance boots (bigger bundles = slower), Node runtimes nodejs22.x and nodejs24.x (nodejs20.x deprecated in April 2026).
  • Lambda can stream responses (useful for SSR and AI output) through function URLs or API Gateway.
  • Each function instance handles one request at a time, so a spike creates many instances and many DB connections: use RDS Proxy or another pooler.
  • Containers: a long-running Node process handles many concurrent requests, keeps connections and in-memory caches warm, supports WebSockets easily; you manage scaling rules, health checks and capacity.
  • Pick serverless for spiky or low traffic, event processing (S3 uploads, queues, cron) and small teams; containers for steady high traffic, long connections, heavy CPU or predictable cost.
  • Edge functions (Cloudflare Workers, Vercel edge) run small Web-standard code near users: great for redirects, auth checks and personalisation, poor for heavy database work far away.
  • AWS App Runner stopped taking new customers in April 2026; AWS points to ECS Express Mode for simple container apps.

The red pen

Common traps: mistake → fix

  • Mistake: Serverless is always cheaper

    Fix: at steady high traffic, containers usually cost less.

  • Mistake: Lambda keeps my in-memory cache between requests

    Fix: only while that instance stays warm; never rely on it.

  • Mistake: Edge is always faster

    Fix: if the data lives in one region, extra round trips from the edge can make it slower.

Easy to hard

Questions interviewers ask, easy to hard

  1. Serverless vs containers: how do you choose?
  2. What is a cold start and how do you reduce it?
  3. Why do Lambdas and Postgres connections clash?
  4. Where would you run a WebSocket server?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

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