What is serverless? Explained with taking a taxi instead of owning a car
Serverless means a cloud provider runs your code only when it is needed and bills you for that time. Like taking a taxi: you pay per trip, not for a car parked outside.
- Author
Umair Mateen- Published
- Reading time
- 5 min
- Category
- DevOps
In one sentence: Serverless is a way of running software where a cloud provider looks after the servers, starts your code only when something needs doing, and charges you for the time it actually runs, not for machines sitting idle.
The everyday picture
Think about getting around a city. One option is to own a car. You pay for it whether you drive or not. You fix it, insure it and find somewhere to park it, even on days it never moves.
The other option is to take a taxi. You book a ride when you need one. A car turns up, takes you where you are going, and the meter stops when you get out. You never think about oil changes. If ten people need rides at once, ten taxis come.
Serverless works like the taxi. There are still cars on the road: there are still servers. You just do not own or look after them. You pay for each trip your code takes.
An event books the ride, the platform sends a copy of your code, it does the job, and billing stops when it finishes. No job, no taxi, no charge.
How it works, step by step
- Something happens (a ride is booked). A customer submits a form, a file is uploaded or a set time arrives. This is called an event, and it is what wakes your code up.
- The cloud platform (the dispatcher) sees the event and sends a ready copy of your code to handle it. You never choose or set up the machine it runs on.
- Your function (the taxi) does one job: saves the form, resizes the photo, sends the email. If no copy was ready, the platform has to start one first. This short wait is called a cold start, like waiting for a taxi to arrive from across town.
- The result is delivered (the drop-off), and the copy is free for the next job.
- The meter stops (billing). You are typically charged for the number of requests and the time and memory each one used. When nothing is happening, the platform scales down to zero, so there are no idle machines to pay for.
Try it · Side by side
Own the car or call a taxi?
Tap what matters to you (pick one or more) and see which option fits.
Own a car (your own server)
- You pay for the server even when it sits idle.
- A steady monthly price can work out cheaper.
- Your team keeps the server patched and running.
- A job can run for as long as it needs.
- You must add capacity yourself in time.
- Easier: a server is a server.
Take a taxi (serverless)
- You pay only while your code runs.
- Paying per run can add up for constant heavy use.
- The provider handles the machines for you.
- Each run has a time limit set by the provider.
- The platform adds copies automatically.
- Harder: each provider has its own triggers and tools.
Pick what matters to you and the better fit lights up.
Where the picture stops
- A taxi driver may remember you. A serverless function usually does not. Each run is meant to start fresh, so anything worth keeping, such as orders or customer records, must be saved in a separate database or storage service.
- You can take a taxi as far as you like. Serverless platforms set limits on how long one run may last and how much memory it may use, so very long jobs need a different home.
- Switching taxi firms is easy. Moving serverless code between cloud providers is not, because each provider has its own triggers, settings and tools. Google Cloud and IBM both list this vendor lock-in as a drawback.
Why it matters for your business
- Lower cost for uneven work: if a task runs a few times an hour, or spikes once a month, you pay for those runs, not for a server waiting all day.
- Less to look after: the provider handles server upkeep, security patches and adding capacity, so your team spends its time on the product.
- Handles sudden rushes: the platform adds more copies automatically when many requests arrive at once, then removes them again. See scaling for why that matters.
- A trade-off to plan for: cold starts can add a short delay, and steady, round-the-clock heavy work can cost more than a server you rent by the month. IBM notes long-running applications can be more expensive on serverless.
Try it · Myth or fact
Serverless: myth or fact?
Decide for yourself first, then tap each statement to check it.
0 of 4 checked
An example
Imagine a small online flower shop. Most of the year it gets a few orders an hour. Before one big holiday, orders jump for two days.
Its order confirmations and receipt emails run as serverless functions. On quiet days, a function wakes for each order, sends the email and stops, so the shop pays for a few seconds of work. On the busy days, the platform runs many copies at once, and nobody has to add servers in a hurry. The shop keeps its product catalogue in a database, because the functions themselves do not remember anything between runs.
Frequently asked questions
Does serverless mean there are no servers?
No. The code still runs on servers in the provider's data centres. "Serverless" means you do not set up, manage or pay for those servers directly.
What is a cold start?
It is the short delay when the platform has to start a fresh copy of your code because none is ready. Later requests handled by an already running copy are usually faster.
Is serverless cheaper than a normal server?
Often for work that comes in bursts or sits idle much of the time, because you pay per use. For steady, heavy work that runs all day, a server you rent continuously can work out cheaper.
What are examples of serverless services?
AWS Lambda, Google Cloud Run functions and Azure Functions are well-known ones. Each runs your code in response to events and bills for the work done.
Related explainers
The DevDrift sets up cloud hosting and deployments for web platforms: see how.
Sources
Could you explain this to a colleague now?
Mark it and posts that mention it will show a tick. Saved in this browser only.