Write functions, let the cloud run them on demand, and pay only while they run.
Serverless means you write small pieces of code (functions) and a cloud provider runs them for you, only when something asks. You do not set up, patch or watch any servers.
In the classic way, you rent a server (or a virtual machine), install your app, keep it running 24 hours a day, and worry about updates, crashes and how many servers you need. You pay whether anyone visits or not.
In the serverless way, you hand the platform a small function, such as "resize this image" or "save this order". You also tell it what should trigger the function: an HTTP request, a new file, a message in a queue, or a timer. When a trigger happens, the platform finds a free machine, starts your code, runs it and then can throw the machine away.
There are two common flavours. FaaS (Function as a Service, like AWS Lambda) runs your code. BaaS (Backend as a Service, like Firebase or managed databases and auth) gives you ready-made backend parts, so you write even less code. Most serverless apps mix both.
| Part | What it does | Examples |
|---|---|---|
| FaaS (functions) | Runs your code when triggered, then stops | AWS Lambda, Azure Functions, Google Cloud Functions, Cloudflare Workers |
| Triggers | The event that starts a function | HTTP, file upload, queue message, database change, timer |
| API gateway | A front door that turns HTTP requests into function calls | Amazon API Gateway, Azure API Management |
| Managed data stores | Storage that is also serverless (scales and bills by use) | DynamoDB, S3, Firestore, Aurora Serverless |
| BaaS | Ready-made backend features | Firebase, Auth0, Cognito, Supabase |
| Orchestration | Joins many functions into one workflow with retries | AWS Step Functions, Azure Durable Functions |
| Idea | How it helps | Cost |
|---|---|---|
| Keep the function small | Less code to download and load | More careful packaging |
| Fast runtimes (Node.js, Go, Python) | They start faster than heavy ones | Language choice may be limited |
| Provisioned / reserved copies | A number of copies are always ready | You pay for them even when idle |
| Do set-up outside the handler | Connections and settings are made once and reused on warm calls | State must be safe to reuse |
| Scheduled warm-up ping | Keeps a copy alive | Hacky, and not reliable for bursts |
A simplified model with no random numbers. One server runs 4 requests at once and costs 1 unit per second. Serverless costs 3 units per busy second but nothing when idle, and allows 100 copies at once. Real prices differ by provider.
| Term | Meaning in easy words |
|---|---|
| Function (FaaS) | A small piece of code that the platform runs when a trigger fires |
| Trigger / event source | What starts a function: HTTP, file, queue, timer, database change |
| Cold start | The extra delay when a new copy of the function must be started |
| Warm start | Running on a copy that is already started and waiting |
| Stateless | Keeps nothing between calls. Anything important is stored elsewhere |
| Concurrency limit | The most copies of your function that may run at the same time |
| Timeout | The longest time one run may take before the platform stops it |
| BaaS | Backend as a Service: ready-made backend features like auth or a database |
| Scale to zero | When nobody uses the app, no copies run and the cost is zero |
| Vendor lock-in | Being tied to one cloud provider's special features |
| Provisioned concurrency | Copies kept ready in advance to avoid cold starts, at a fixed price |
| Choice | We gain | We lose |
|---|---|---|
| Serverless instead of servers | No operations work, automatic scaling | Control over the machine and runtime |
| Pay per run | A bill that follows real use | Cost can surprise you under steady or runaway load |
| Provisioned copies | Steady, low latency | You pay even when idle, like a server |
| Many tiny functions | Simple, separate pieces | More wiring, more to monitor |
| Managed services (BaaS) | Less code to write and run | Lock-in and less flexibility |
| Scale without limit | Handles any spike | Can overload the database behind it |