, , ,

Serverless Explained: What It Is and When to Use It (Cloud for Beginners, Part 12)

Serverless explained for freshers: what it means, how Functions as a Service work, cold starts, a real cost breakdown, and when not to use it.

Cloud for Beginners · Part 12 of 18
TL;DR. Serverless means you write a small function, the cloud runs it only when something triggers it, and you pay just for the milliseconds it runs. There are no servers for you to start, patch or keep alive. The free grant is generous enough that a hobby project often costs nothing: AWS Lambda and Azure Functions both include 1 million requests and 400,000 GB-seconds a month, and Google Cloud Run functions include 2 million requests. The catch most freshers hit first is the cold start, the short delay when a function wakes up from idle.
Who this is for. Freshers and new IT staff who keep seeing the word serverless on job posts and in team chats and want a clear picture before they touch a real function. No coding background beyond reading a few lines is needed.

Serverless still runs on servers. The name is a small fib that trips up almost everyone on their first day. What actually disappears is your job of looking after those servers. You do not pick a machine size, you do not install patches, you do not keep anything running through the night. You hand the cloud a piece of code and a rule for when to run it, and the provider finds a server, runs your code, then takes the server away the moment it is done. You get billed for the run, not for the waiting. That shift is the whole idea, and once it clicks, a lot of cloud job postings start to make sense.

A porch light that bills by the second

Think of a motion-sensor porch light. It sits dark and costs you nothing. Someone walks up the path, the sensor fires, the light switches on, does its one job, and switches off a few seconds later. You pay only for the seconds it was lit. A normal always-on server is the opposite: a floodlight you leave burning all night just in case a visitor turns up at 3am. Most of the night it lights an empty path and still runs up the bill. Serverless is the motion sensor. Your code stays dark and free until an event wakes it, runs for a few hundred milliseconds, and goes quiet again.

So who deleted the server?

Nobody. The server is still there. AWS, Azure or Google owns it, shares it across thousands of customers, and only charges you for the slices of time your function actually used it. Because the machine is shared and handed out on demand, the provider keeps it busy and passes the saving on. You trade control, since you cannot log into the box, for freedom from babysitting it. For a fresher that is a fair deal: one less thing that can break at 2am because of something you forgot to patch.

Always-on serverServerlessRunning 24 / 7idle most of the timeBilled every hourRuns only on a triggerBilled only for these slivers
An always-on server bills every hour even when the path is empty. Serverless bills only for the short bursts when your code actually runs.

Functions as a Service, in plain terms

The flavour of serverless you will meet first is Functions as a Service, usually shortened to FaaS. You write one function, a short block of code that does one thing: resize an uploaded photo, send a welcome email, save a form to a database. You do not write the loop that waits for requests and you do not manage the web server. The platform does that part. You only say what should happen and what sets it off.

What sets it off

A trigger is the event that runs your function. Common ones: an HTTP request hits a URL, a file lands in storage, a message arrives on a queue, or a timer fires every five minutes. One function, one trigger, one job. String a few of these together and you have a working application without ever renting a server you have to keep alive.

Event / triggerHTTP, file, timerYour functionruns for a momentResultemail sent, file savedIdle and free between events
An event triggers your function, it runs once, returns a result, then scales back to zero until the next event.

Each of the big three has its own FaaS, and the free grants are big enough that learning and small side projects usually cost nothing. The names and limits below were checked against the providers in 2026; the prices apply once you pass the free grant, in standard US regions.

ProviderServiceFree grant each monthAfter the free grant
AWSLambda1M requests + 400,000 GB-seconds0.20 USD per million requests + compute
Microsoft AzureFunctions (Consumption)1M requests + 400,000 GB-seconds0.20 USD per million + 0.000016 USD per GB-s
Google CloudCloud Run functions2M requests + 180,000 vCPU-s + 360,000 GiB-s0.40 USD per million requests + compute
Why this matters in your first job. You will not design a serverless system in week one. You will read and tweak one that already exists. Knowing that a function is triggered by an event, runs briefly, and scales to zero when idle lets you answer the question every new hire freezes on: why did this code run at 2am with nobody around? Because a file landed in a bucket and fired the trigger. Spotting that makes you useful on day one.

Cold starts, the thing nobody warns you about

This is the one piece worth slowing down on, because it surprises every newcomer and it shows up in interviews. When a function has not run for a while, the platform has nothing ready for it. The first call has to find a server, copy your code onto it, and start the language runtime before your code even begins. That extra wait is a cold start, and it can add anywhere from a few hundred milliseconds to a couple of seconds depending on the language and how much code you ship.

Once that instance is warm, it stays ready for a while, and the next calls answer in milliseconds. So your function feels slow on the first hit after a quiet spell and fast after that. Nothing is broken. The platform is just building the kitchen before it can cook your first order. Smaller code and faster-starting runtimes like Python and Node.js cut the wait; heavier ones like Java and .NET take longer to warm up.

Cold startplatform wakes up: find server, load code, start runtimeyour code runsWarm startyour code runstime goes this waylonger
A cold start pays the grey setup time before your code begins. A warm start skips straight to your code.
Gotcha: the default timeout is 3 seconds. AWS Lambda ships every new function with a 3-second limit. Your code calls a slow database, takes four seconds, and the run is killed mid-way with a Task timed out after 3.00 seconds error in the logs. Nothing is wrong with your code; the default is just cautious. Raise the timeout in the settings, up to a hard ceiling of 900 seconds, which is 15 minutes. If a job genuinely needs longer than 15 minutes, a serverless function is the wrong tool and a container or batch job is the right one.
Real interview question. What is a cold start, and how would you reduce it? A strong answer: a cold start is the extra delay the first time a function runs after sitting idle, because the platform must find a server, load your code, and start the runtime before your code begins. Once warm, the same function answers in milliseconds. You cut cold starts by keeping the function small, choosing a fast-starting runtime, giving it a little more memory (which also gives it more CPU), and on AWS by using provisioned concurrency to keep a few instances warm. Then add the honest line that gets you the nod: for most low-traffic apps a one or two second cold start does not matter, so do not pay to fix a problem you do not have.

What a serverless bill actually looks like

Serverless billing has two parts: a tiny charge per request, and a charge for compute measured in GB-seconds, which is memory multiplied by run time. The memory part is where people get surprised, because you pay for the memory you reserve whether your code needs it or not. Here is a real calculation you can follow with a phone calculator.

Worked example: a photo-resize function on AWS Lambda.
Memory 512 MB (0.5 GB), runs 400 ms each time, called 3 million times in a month.

Requests: 3,000,000 minus the 1,000,000 free = 2,000,000 billable, at 0.20 USD per million = 0.40 USD.
Compute: 0.5 GB times 0.4 seconds times 3,000,000 calls = 600,000 GB-seconds. Subtract the 400,000 free and you bill 200,000 GB-seconds at about 0.00001667 USD each = 3.33 USD.
Total: about 3.73 USD for the month. Three million image resizes for less than a cup of coffee.

Now change one number. Bump memory to 2 GB and the compute line alone jumps to roughly 16 USD, because you pay for reserved memory whether the code uses it or not. Right-sizing memory is the single biggest lever on a serverless bill.

When serverless is the wrong choice

Marketing decks like to say serverless is always cheaper. That is not true, and believing it will burn you. Serverless wins when traffic is spiky or low: a form that gets a few hundred submissions a day, a nightly report, a webhook that fires now and then. The code is idle almost always, so you pay almost nothing. Flip it around. A service running flat out, handling steady heavy traffic every second of every day, never gets to be idle, so the per-request pricing that saved you money at low volume now costs more than simply renting a server that runs all the time.

My rule, after years of building both kinds: reach for serverless first for anything event-driven or bursty, and move to containers or virtual machines once a workload is busy enough that a server would stay near fully used anyway. The break-even point is real. Good engineers run the numbers for their own traffic instead of trusting the slogan on the slide.

Pick by the workloadBursty or rareeventsSteady heavy loadall dayOne run over15 minutesServerless fitsContainer or VMBatch job, not FaaS
Match the tool to the traffic shape. Serverless is not the answer to every workload.
Try it yourself (free, about 20 minutes).
On any one provider free tier, create a single HTTP-triggered function that returns the current time. AWS calls it a Lambda with a Function URL, Azure calls it an HTTP trigger, Google calls it a Cloud Run function. Use the in-browser editor so you install nothing on your laptop. Deploy it, then open the URL twice in a row.
How to check it worked: the first call is noticeably slower than the second. That gap is your cold start, live. You just saw the most-discussed quirk of serverless with your own eyes, and it cost nothing.

Serverless is bigger than just functions

Functions are the front door, but the same pay-for-what-you-use idea now covers more of the stack. Serverless databases scale their capacity up and down on their own and bill by the request or by storage, so a quiet table costs almost nothing. Managed queues, object storage and API gateways all follow the same pattern: no server for you to size, a free grant to start, and a bill that tracks real use. The mental model carries straight over. If a managed service scales to near zero when idle and charges by use rather than by the hour, it is serverless in spirit even if the word function never appears.

This matters because real systems mix these pieces. A small app might be an API gateway in front of a function that reads and writes a serverless database, with files landing in object storage that fires a second function. None of it is a machine you log into. You wire the parts together and watch the bill, which is a different skill from racking hardware.

In practice. The first serverless project you inherit will almost never be a single function. It will be a handful of functions plus a queue, a database and an API gateway glued together. Read the trigger on each function first; that one line tells you what wakes it, and it is the fastest way to map a system nobody has documented.

FAQ

Is serverless really server-less?
No. Servers still run your code. You just never see, choose or manage them. The provider owns and shares the machines and bills you only for the time your function runs.

Is Lambda always cheaper than a normal server like EC2?
No. For low or spiky traffic, usually yes. For a service under constant heavy load, a right-sized server or container often wins, because you stop paying a small premium on every single request. Work out your monthly call volume before you decide.

What languages can I use?
The big three support the common ones out of the box: Python, JavaScript and Node.js, Java, C# and .NET, Go and more. Python and Node are the usual starting points for freshers because they start fast and keep cold starts short.

Can a serverless function run forever?
No. AWS Lambda caps a single run at 15 minutes. Long or always-on jobs belong in a container or VM. Serverless is built for short, event-driven bursts of work.

How is serverless different from containers?
A container packages an app that you still run and keep alive on a cluster. A serverless function runs only on an event and scales to zero when idle. Many teams use both: containers for the steady core, functions for the bursty edges.

Hold three ideas and you can follow almost any serverless conversation: code that runs only on a trigger, billing by the millisecond, and the cold start you pay for in latency rather than dollars. Everything else you can look up when you need it. The fastest way to make it stick is to deploy one tiny function today and watch the first call lag behind the second.

Your move: open a free tier, deploy the time function from the Try it yourself box, and refresh it twice. If the second call is faster than the first, you have just watched a cold start and a warm start back to back, and you understand serverless better than most people who only read about it.
Cloud for Beginners · Part 12 of 18
« Previous: Part 11  |  Complete Guide  |  Next: Part 13 »

References

About The Author


Discover more from Journal of Intelligent Infrastructure – By Dr Pranay Jha

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Architect’s Toolkit

About the Author

Dr. Pranay Jha is a Cloud and AI Consultant with 18+ years of experience in hybrid cloud, virtualization, and enterprise infrastructure transformation. He specializes in VMware technologies, multi-cloud strategy, and Generative AI solutions. He holds a PhD in Computer Applications with research focused on Cloud and AI, has published multiple research papers, and has been a VMware vExpert since 2016 and a VMUG Community Leader.

Discover more from Journal of Intelligent Infrastructure - By Dr Pranay Jha

Subscribe now to keep reading and get access to the full archive.

Continue reading