What is serverless computing? It is a cloud model in which the provider runs and scales the servers for you, and you pay only for the time your code actually runs. Servers still exist, but you do not provision, patch or size them. You write functions or small services, connect them to events such as web requests, file uploads or messages, and the platform does the rest. This guide explains how serverless works, the main building blocks, where it shines, where it struggles and how to decide whether it fits your workload.
Short answer: Serverless computing lets you run code without managing servers. The platform starts your function when an event arrives, scales it from zero to thousands of instances and bills per execution. It suits event driven, spiky and unpredictable workloads, and is less suited to constant heavy computation or strict latency needs.
What is serverless computing?
The serverless computing article on Wikipedia describes two overlapping ideas. Function as a service, such as AWS Lambda, Azure Functions and Google Cloud Functions, runs short pieces of code on demand. Backend as a service supplies managed databases, authentication and storage so you write less infrastructure code. Both sit within the wider picture in what is cloud computing.
How serverless works

- An event occurs. A user calls an API, a file is uploaded, a message arrives or a timer fires.
- The platform starts your function. If no instance is warm, it creates one. This first start is known as a cold start.
- Your code runs. The function reads the event, does its work and talks to managed services such as databases or queues.
- The platform scales. More events create more instances in parallel, up to configured limits.
- You pay for usage. Billing is based on the number of requests and the duration and memory of each run.
- Idle time costs nothing. When no events arrive, instances are removed and compute charges stop.
Serverless compared with containers and virtual machines
| Aspect | Virtual machines | Containers | Serverless |
|---|---|---|---|
| You manage | Operating system, runtime, scaling | Images, orchestration. See what is Kubernetes | Code and configuration only |
| Scaling | Manual or scheduled | Autoscaling with tuning | Automatic and per event |
| Billing | Per hour of running server | Per node or pod | Per request and run time |
| Startup time | Minutes | Seconds | Milliseconds to seconds |
| Best for | Legacy or steady workloads | Long running services | Event driven and spiky work |
Typical serverless use cases
| Use case | Example | Why it fits |
|---|---|---|
| Web and mobile APIs | Order lookup endpoint | Traffic varies by hour |
| File processing | Resize images on upload | Work arrives in bursts |
| Scheduled jobs | Nightly report | Runs minutes a day, pays for minutes |
| Stream and message handling | Process payments events. See what is event driven architecture | Scales with the queue |
| Automation and glue | Respond to cloud alerts | Small code, many triggers |
| Data pipelines | Transform files as they land. See what is a data pipeline | No idle cluster |
Benefits and trade-offs
| Benefits | Trade-offs |
|---|---|
| No server management or patching | Cold starts can add latency |
| Automatic scaling to zero and to very high load | Execution time and memory limits per function |
| Pay per use, which suits variable demand | Costs can exceed servers for constant heavy load |
| Fast to build and deploy small services | Harder local testing and debugging across many functions |
| Built in high availability | Risk of provider lock in through proprietary triggers |
Best practices for serverless
- Keep functions small, single purpose and stateless. Store state in a database or cache.
- Make handlers idempotent, because events may be delivered more than once.
- Set sensible memory, timeout and concurrency limits to control cost and protect downstream systems.
- Reduce cold starts with small packages, lean dependencies and provisioned concurrency for critical paths.
- Use infrastructure as code to define functions and triggers. See what is infrastructure as code.
- Add tracing and structured logs from day one. See what is observability.
- Apply least privilege permissions to each function.
Common mistakes
- Moving a long running, steady workload to functions and then being surprised by the bill.
- Chaining many functions synchronously, which multiplies latency and failure points.
- Ignoring concurrency limits and overwhelming a database during a spike.
- Putting secrets in environment variables without a secrets manager.
- Having no plan for observability, so failures are impossible to trace.
Our cloud migration service helps you decide which workloads suit serverless, containers or virtual machines, and our API development service builds serverless APIs with proper security and monitoring.
Cost, security and operations in serverless
| Area | What to plan for | Practical tip |
|---|---|---|
| Cost | Cost grows with requests and run time, so a runaway loop can be expensive | Set budgets, alarms and concurrency limits |
| Security | Each function has its own permissions and attack surface | Grant least privilege per function and validate every input |
| Networking | Functions that reach private databases need network configuration | Use private connectivity and watch for added latency |
| Testing | Behaviour depends on events and cloud services | Combine unit tests with a small number of cloud based integration tests |
| Observability | Many small functions make failures hard to trace | Use correlation ids, structured logs and distributed tracing |
| Deployment | Many functions need consistent releases | Use a pipeline. See what is CI/CD |
A useful rule is to estimate the monthly cost at your expected steady load before you commit to the model. If a function runs constantly at high volume, compare it with a small container service. If it runs in bursts, serverless almost always wins on both cost and effort.
When serverless is not the right answer
- Workloads that need very low and predictable latency on every request, where a cold start is unacceptable.
- Long running jobs that exceed function time limits, such as large batch training.
- Applications that need specialised hardware or a particular operating system setup.
- Steady, high volume services where a reserved server or container is cheaper.
- Teams with no capacity to learn event driven design and distributed debugging.
A worked example: image processing for a marketplace
An online marketplace lets sellers upload product photos. Each upload must be resized into five sizes and checked for prohibited content. On a fixed pool of servers the team had to size for the busiest Saturday, so machines sat idle most of the week. With serverless, each upload to a storage bucket triggers a function that creates the five sizes and sends the image to a moderation service. Ten uploads or ten thousand are handled the same way.
Monthly compute cost falls by roughly two thirds because the company pays only for processing time. The team also removes patching and capacity planning from its backlog. The trade-off was learning to design for retries: the first release processed some images twice when an event was redelivered, which was fixed by recording a processed marker for each file. That lesson, making functions safe to repeat, applies to almost every serverless design.
Key takeaways
- Serverless runs code on demand without you managing servers, and bills by usage.
- It scales automatically and suits event driven, bursty and unpredictable workloads.
- Cold starts, limits and lock in are the main trade-offs.
- Design small, stateless, idempotent functions with good observability.
- Choose serverless, containers or virtual machines by workload, not by fashion.
Quick glossary
| Term | Meaning |
|---|---|
| Function as a service | Code run on demand in response to events |
| Cold start | Extra delay when a new instance starts |
| Idempotent | Safe to run more than once with the same result |
| Concurrency | Number of instances running at the same time |
| Event source | What triggers a function, such as a queue or upload |
Read next: What Is Container Orchestration? Kubernetes and Beyond · What Is a Service Mesh? Istio, Linkerd and How It Works · What Is Cloud Security? Shared Responsibility and Controls
Frequently asked questions
What is serverless computing in simple terms?
It is a way to run code in the cloud without managing servers. You supply the code, the provider runs and scales it, and you pay only while it executes.
Are there really no servers in serverless?
There are servers, but the provider owns and manages them. You do not provision, patch or scale them yourself.
What is a cold start?
A cold start is the extra delay when the platform creates a new function instance because none is ready. Smaller packages and provisioned concurrency can reduce it.
Is serverless cheaper?
Often for spiky or low traffic workloads, because idle time is free. For constant heavy load, containers or virtual machines can cost less.
What are examples of serverless services?
AWS Lambda, Azure Functions and Google Cloud Functions run code on demand. Managed databases, queues and storage also follow the serverless model.
What is the difference between serverless and containers?
Containers package an application you still deploy and scale. Serverless hides the runtime and scales per event. See also our guide to Kubernetes for container orchestration.
Can serverless run a whole application?
Yes, many applications combine functions, managed databases, queues and storage. Complex or latency sensitive parts may still suit containers.
What are the main risks of serverless?
Cold start latency, execution limits, hard to trace distributed flows and dependence on one provider. Good design and observability reduce these risks.
