Serverless
A cloud execution model where the provider manages all infrastructure and you pay only for actual compute time. AWS Lambda, Vercel Functions, and Cloudflare Workers are serverless.
What is Serverless?
In short
Serverless is a cloud execution model where the provider runs and scales your code on demand, and you pay only for the actual compute consumed while it runs, with nothing billed when it sits idle. You still use servers, but you never provision, patch, or scale them yourself. AWS Lambda, Cloudflare Workers, and Vercel Functions are common examples.
What serverless actually means
Serverless does not mean there are no servers. It means you stop thinking about servers. You hand the provider a unit of code, usually a single function, and the provider decides where to run it, how many copies to run, and when to shut them down. You are billed per invocation and per millisecond of run time instead of per hour of a rented machine.
The classic shape is Functions as a Service (FaaS): a small function triggered by an event such as an HTTP request, a file landing in storage, a message on a queue, or a scheduled timer. AWS Lambda launched this category in 2014. The same idea now extends to serverless databases (Neon, Aurora Serverless), serverless container platforms (AWS Fargate, Google Cloud Run), and edge runtimes (Cloudflare Workers).
The defining property is scale-to-zero. If no requests come in, nothing runs and you pay nothing for compute. When 5,000 requests arrive at once, the platform spins up enough instances to handle them, then tears them down when traffic drops.
How it works under the hood
When a request hits a function that has no running instance, the platform does a cold start: it allocates a sandbox (a microVM like AWS Firecracker, or a lightweight V8 isolate on Cloudflare), loads your code and dependencies, then runs your handler. That setup adds latency, typically 100ms to over 1 second for a heavy Node.js or Java function, and near zero for a V8 isolate.
Once an instance is warm, the platform reuses it for later requests, so subsequent calls skip the cold start. Each instance usually handles one request at a time, so concurrency is achieved by running many instances in parallel rather than threading inside one process. AWS Lambda, for example, defaults to 1,000 concurrent executions per account per region.
Because instances are short-lived and stateless, anything you need to keep has to live elsewhere: a database, object storage, or a cache like Redis. The platform enforces hard limits too, such as Lambda's 15-minute maximum execution time and a deployment package size cap, which shapes what kinds of work fit.
When to use it and the trade-offs
Serverless fits spiky, event-driven, or unpredictable workloads: webhooks, image processing on upload, cron jobs, API backends with uneven traffic, and glue between cloud services. If your traffic is bursty or you are early and do not want to pay for idle servers, scale-to-zero is a real cost win. It also removes patching, capacity planning, and autoscaling config from your plate.
The trade-offs are concrete. Cold starts hurt latency-sensitive paths. Per-request pricing gets expensive at sustained high volume, where a reserved instance or container is cheaper. The stateless, short-lived model rules out long-running jobs, large in-memory caches, and persistent WebSocket connections in many runtimes. You also inherit vendor lock-in, since triggers, limits, and runtimes differ across providers.
A useful rule of thumb: serverless wins when load is intermittent and you value zero idle cost and zero ops, and loses when load is steady and high, latency budgets are tight, or work runs for minutes to hours.
Where it is used in production
AWS Lambda
The original FaaS platform; runs functions in Firecracker microVMs triggered by API Gateway, S3, SQS, and dozens of other events.
Cloudflare Workers
Runs JavaScript and WASM in V8 isolates at the edge with near-zero cold starts, executing close to the user across hundreds of locations.
Vercel
Deploys Next.js API routes and server components as serverless and edge functions, scaling automatically per request with no server config.
Netflix
Uses Lambda for event-driven tasks like encoding pipeline triggers, backup validation, and security automation that run only when files or events arrive.
Frequently asked questions
- Does serverless really mean no servers?
- No. Servers still run your code; you just never see, provision, or manage them. The provider handles the machines, scaling, and patching, and you only pay for the compute time your code actually uses.
- What is a cold start and why does it matter?
- A cold start is the extra delay when the platform has to create a fresh instance, load your code, and initialize dependencies before running your handler. It can add 100ms to over a second for heavy runtimes, which hurts latency-sensitive requests. Warm instances skip this, and lightweight runtimes like V8 isolates make it nearly disappear.
- Is serverless cheaper than running a server?
- It depends on traffic. For spiky or low-volume workloads, scale-to-zero means you pay nothing while idle, which is usually cheaper. For steady, high-throughput workloads, per-request pricing can cost more than a reserved instance or container running 24/7.
- What should I not use serverless for?
- Avoid it for long-running jobs (AWS Lambda caps at 15 minutes), workloads needing large persistent in-memory state, low-latency paths that cannot tolerate cold starts, and steady high-volume traffic where a dedicated instance is cheaper.
- How does serverless handle state if functions are stateless?
- It does not store state in the function itself. You keep state in external services: a database such as DynamoDB or Postgres, object storage like S3, or a cache like Redis. Each invocation reads and writes there, so any instance can serve any request.
Learn Serverless hands-on
This page explains the idea. The full lesson lets you step through the ring as servers join and leave, read the implementation, and check yourself with a quiz. It is one of 760+ lessons in the System Design Masterclass, from your first API call to distributed consensus. Eleven Foundation lessons are free, no signup. Lifetime access is ₹499 in India or $7.99 worldwide, one payment, no subscription.
Related lessons
Lessons that touch on Serverless as part of a larger topic.
FaaS
Functions as a Service, the compute primitive behind serverless, where each function is an independent unit of deployment
intermediate · cloud infrastructure
Cold Start
The latency penalty when serverless functions wake up, what causes it, how to measure it, and how to minimize it
intermediate · cloud infrastructure
Warm Instances
Pre-initialized execution environments that eliminate cold start latency at the cost of idle compute
intermediate · cloud infrastructure
See also
Related glossary terms you might want to look up next.
Auto Scaling
Automatically adding or removing compute instances based on current demand. Scales out during traffic spikes and scales in during quiet periods to save cost.
Docker
A platform for packaging applications into lightweight, portable containers. 'Works on my machine' becomes 'works everywhere.'
Microservices
An architecture where an application is split into small, independent services that communicate over the network. Each service owns its own data and can be deployed separately.
Virtual Machine
A software emulation of a physical computer running its own OS on shared hardware. Heavier than containers but provides stronger isolation.
Hypervisor
Software that creates and manages virtual machines by abstracting physical hardware. Type 1 (bare-metal) runs directly on hardware; Type 2 runs on an OS.
Cloud Region
A geographic area containing one or more data centers (availability zones). Choosing the right region reduces latency and satisfies data residency requirements.