Serverless computing explained in one sentence: it is a way of running code in the cloud without managing servers, where you pay only for the time your code actually runs. The name is misleading, because servers are still involved, but they belong to the cloud provider, not to you. The short answer is that serverless suits event-driven work, uneven traffic and small teams that want to ship without operating infrastructure, and it suits those jobs far better than it suits long-running or constant workloads.
AWS Lambda, launched by Amazon in 2014, made the idea mainstream, and every major cloud provider now offers something similar, including Azure Functions and Google Cloud Functions. This guide explains how serverless works, what it costs, where its limits bite, and how to decide whether it fits your project.
Key takeaways
- Serverless means no server management for you: the provider runs your code, scales it and patches the underlying platform.
- You pay for execution time and requests, not for idle servers, which makes costs track real usage.
- Functions are event-driven: they run when something happens, such as an upload, a message or a web request.
- Cold starts add delay when a function has been idle, which matters for latency-sensitive applications.
- Functions have limits on run time, memory and package size, so they suit short tasks rather than long jobs.
- Serverless is best for spiky or unpredictable traffic; steady, heavy workloads are often cheaper on fixed servers.
How serverless works
In the traditional model, you rent a server, or a virtual machine, and it runs all the time whether anyone uses it or not. You install the operating system, patch it, watch its health, and scale it by adding more machines when traffic grows. Serverless removes all of that from your side. You write a function, a small piece of code that does one job, and you tell the provider when it should run.
An event triggers the function. That event might be a file uploaded to storage, a message arriving in a queue, a row changing in a database, a scheduled time, or a web request arriving at an address. The provider starts a fresh environment, runs your function, and shuts the environment down when it finishes. If ten events arrive at once, the provider runs ten copies in parallel. If none arrive, nothing runs and, in the pure pay-per-use model, you pay nothing.
That scaling is automatic and fast, which is the main reason teams choose serverless. A traditional server needs time to start and configure before it can take traffic, while a serverless platform can go from zero to thousands of simultaneous executions without you doing anything. The trade-off is control: you cannot log into the machine, tune the operating system, or keep a process running between requests unless the platform offers a way to do it.
Functions as a service and backend as a service
Serverless covers two related ideas, and it helps to keep them apart. Functions as a service, usually shortened to FaaS, is the model described above: you write functions and the provider runs them. AWS Lambda, Azure Functions and Google Cloud Functions are the best-known examples. Backend as a service, or BaaS, is different: the provider runs a whole backend capability for you, such as authentication, a database or file storage, and you call it from your application without managing it.
In practice, most serverless applications combine the two. A typical setup might use functions for the custom logic, a managed database for storage, a managed authentication service for sign-in, and a managed queue to pass work between functions. The more of the backend you hand to managed services, the less infrastructure you operate, but the more your application depends on one provider’s services and pricing.
What serverless costs
Serverless pricing follows usage. You generally pay for the number of requests and for the compute time your functions use, measured in gigabyte-seconds, which combines how much memory you allocate with how long the function runs. The major providers include a free tier each month that covers a generous number of requests and a block of compute time, which makes small projects and experiments very cheap or free.
That model is kind to uneven traffic. A website that is quiet overnight and busy at lunchtime pays for the busy hours and almost nothing for the quiet ones, while a rented server costs the same around the clock. The cost curve flips for steady, heavy use. A function that runs constantly, or millions of times a day, can cost more than a small server doing the same work, because you pay a premium per unit of compute for the convenience of not managing it. There is no single answer to which is cheaper: it depends on your traffic pattern, and the honest way to decide is to measure your real usage and compare the two bills.
Watch for the costs around the functions, not just the functions themselves. Data transfer out of the cloud, calls to managed databases, and requests through an API gateway all carry their own charges, and a busy application can spend more on those than on compute. Set up billing alerts from the start, and review the bill monthly while the system is new. Our guide to cloud computing for enterprises explains how these services fit into a larger cloud estate, and our guide to language model API pricing covers a similar pay-per-use pattern in a different part of the stack.
| Aspect | Serverless functions | Virtual servers | Containers |
|---|---|---|---|
| You manage | Code and configuration only | Operating system and scaling | Images, orchestration, scaling |
| Scaling | Automatic, to zero | Manual or autoscaling rules | Automatic with an orchestrator |
| Cost when idle | Near zero | Full price, always on | Full price unless scaled to zero |
| Maximum run time | Minutes, per invocation | Unlimited | Unlimited |
| Startup delay | Cold starts possible | Seconds to minutes | Seconds |
| Best for | Events, APIs, spiky traffic | Steady, long-running work | Portable, long-running services |
Cold starts and other limits
A cold start happens when a function runs after being idle. The provider must set up a fresh execution environment, load your code and start its runtime before your code can run, and that adds delay, usually measured in hundreds of milliseconds but sometimes longer for large packages or less common languages. Warm invocations, where an environment is already running, are far faster. Cold starts matter most for user-facing work where every millisecond counts, and they matter least for background jobs where a short delay is invisible.
Providers offer ways to reduce cold starts, such as keeping a number of environments warm, but those options cost money and reintroduce some of the capacity planning serverless was meant to remove. The practical approach is to keep functions small, keep their dependencies lean, and test the latency your users actually experience rather than assuming the worst.
Functions also have hard limits. AWS Lambda, for example, allows a single invocation to run for at most 15 minutes, and other providers set similar caps. Memory is allocated in steps up to a platform maximum, and the deployment package has a size limit. Functions are stateless by design: anything a function needs to remember must be stored in a database, a cache or object storage, not on the function’s own disk. These limits are not flaws; they are the shape of the model, and designing around them is part of using serverless well.

When serverless is the right choice
Serverless fits best when work is event-driven or unpredictable. Processing files as they are uploaded, responding to messages in a queue, running a scheduled cleanup job, or serving an API with traffic that spikes and falls are all natural fits. It also fits small teams well, because it removes the operational work of patching, scaling and monitoring servers, and lets a small group ship a real service without hiring for operations.
It fits less well when work is long-running, constant or stateful. Video encoding that takes an hour, a service that must hold connections open for a long time, or a workload that runs at full tilt around the clock usually belongs on servers or containers, where the cost is predictable and the limits do not apply. Highly latency-sensitive applications can also struggle, because cold starts add a delay that a warm server does not have.
Vendor lock-in deserves honest attention. Functions are small, but the services around them, such as queues, databases, authentication and deployment tooling, are specific to each provider. Moving a serverless application to another cloud is possible, but it is real work, and the more managed services you use, the more work it becomes. Keep your business logic separate from provider-specific code where you can, and make the choice with your eyes open.
Serverless decision checklist
Work through this checklist before choosing serverless for a project.
- Traffic is spiky or unpredictable, or the service should scale to zero when idle.
- Work is event-driven: uploads, messages, database changes, schedules or web requests trigger it.
- Each task finishes in minutes, not hours, and fits the platform’s memory and package limits.
- Your team wants to ship without operating servers, patching systems or planning capacity.
- You have measured the cost: compare the pay-per-use bill against a small always-on server for your real traffic.
- Cold starts are acceptable: test the latency your users will actually feel.
- State lives outside the function, in a database, cache or object storage.
- You accept the provider’s services around the functions, and you have thought about how you would move if you had to.
Frequently asked questions
Is serverless really without servers?
No. Servers still run your code, but the provider owns and manages them. Serverless means you do not provision, patch or scale servers yourself.
What is a cold start?
A cold start is the delay when a function runs after being idle and the provider must set up a fresh execution environment. Warm invocations reuse an existing environment and are faster.
How long can a serverless function run?
It depends on the provider. AWS Lambda allows up to 15 minutes per invocation, and other providers set similar limits. Functions are designed for short tasks, not long-running jobs.
Is serverless cheaper than a virtual server?
It depends on your traffic. Serverless is usually cheaper for uneven or low traffic, because you pay only for what you use. A steady, heavy workload is often cheaper on a fixed server.
Can I run a whole website on serverless?
Yes. Many websites run entirely on serverless functions, static hosting and managed services. It works best for sites with variable traffic and for applications built from small, independent pieces.
What happens if my function fails?
Most platforms retry failed invocations automatically, and events can be sent to a dead-letter queue for later inspection. You should still add logging, alerts and tests, because automatic retries can repeat a failure many times.
The bottom line
Serverless computing trades control for convenience. You give up the server, and in return you get automatic scaling, no patching, and a bill that follows your real usage. For event-driven work and unpredictable traffic, that trade is an easy win.
It is not the right shape for every workload. Long jobs, constant heavy traffic and latency-critical services are usually better on servers or containers. Judge it by your traffic pattern, your team’s capacity and your measured costs, and you will know quickly whether serverless fits.







