Serverless vs Traditional

When to run code as functions the cloud starts on demand, and when to keep servers or containers running: cold starts, concurrency, cost per request against cost per hour, hard limits and the database connection problem.

Overview

Serverless computing means you hand the cloud your code and it runs it only when something happens: an HTTP request, a file upload, a message on a queue, a timer. The provider starts machines as needed, scales them with traffic, stops them when traffic stops, and bills you for the work done rather than for time the machines are up. AWS Lambda, Google Cloud Run functions, Azure Functions and Cloudflare Workers are common examples. The model is often called functions as a service (FaaS).

Traditional here means capacity you keep running: virtual machines, or containers on Kubernetes or a service such as ECS. You choose how many copies run, you pay for each hour they run whether they are busy or idle, and in return nothing starts cold, nothing has a time limit, and each process can hold connections and caches for as long as it likes.

Neither model is better in general. Functions win when traffic is spiky, idle often or event-driven, and when a small team wants no servers to operate. Always-on capacity wins for steady, heavy traffic, long-running work and anything that holds connections. Most real systems use both.

What you will be able to do

  • Explain what happens on a cold start and when it matters to users.
  • Size a function with the concurrency formula and spot a scaling limit before it throttles you.
  • Estimate where paying per request stops being cheaper than paying per hour.
  • Name the limits that rule functions out, and the database connection problem with its fixes.
  • Choose functions, containers or edge isolates for each part of a design.

Key concepts

  • Functions as a service
  • Execution environments
  • Cold and warm starts
  • Provisioned concurrency
  • Concurrency and scaling rate
  • Pay per request vs pay per hour
  • Connection pooling proxies
  • Edge isolates
  • Serverless containers

Interview questions

  • What is a cold start, and how do you deal with it?
  • Your API gets 5,000 requests a second at 200 ms each. Can it run on Lambda?
  • When is serverless cheaper than running containers, and when is it not?
  • Why do functions struggle with relational databases, and what do you do?
  • Which workloads would you not run as functions?
  • How do Cloudflare Workers differ from AWS Lambda?
  • How would you design an image-upload pipeline, and where does serverless fit?
  • How do you limit vendor lock-in with serverless?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio