MainHistoryExamplesRecommended Reading
Explain Like I'm 5 /Infrastructure

What is Serverless?

Help others learn from this page

In serverless architecture, developers deploy backend code in the cloud infrastructure provided by the cloud providers. The key to serverless applications is event-driven architecture — small, decoupled services that publish, consume, or route events. Events are messages sent between services.
AWS/ Documentation
image for entry

Serverless architecture (Baldini et al., 2017)

Serverless is a cloud computing model where you deploy code without managing servers. Instead of provisioning, scaling, and maintaining machines, you write short-lived functions that run on-demand.


What It Is — Technically:

In serverless, the cloud provider (like AWS, Google Cloud, or Vercel) handles the infrastructure. When an event triggers your code — an HTTP request, a cron job, a queue message — your function is executed in a managed environment. You only pay for the time your code runs, measured in milliseconds.

Serverless functions are typically:

  • Stateless (they don’t persist data between runs)
  • Ephemeral (they spin up and shut down automatically)
  • Triggered by events (like API calls, file uploads, DB changes)

How It Works:

  • You write your function (usually in Node.js, Python, Go, etc.)
  • Deploy it to a serverless platform
  • The provider handles scaling, execution, and teardown
  • You’re billed based on usage, not uptime

Under the hood, these platforms often use lightweight containers or WebAssembly modules running inside secure, isolated environments — sometimes even Virtual Machines for compatibility or isolation.

Why You’d Use It:

  • Focus on business logic, not infrastructure
  • Scale automatically with demand
  • No idle cost — you don’t pay when nothing’s happening
  • Quick to deploy for prototypes and production
  • Integrates well with APIs, events, and background tasks

When Not to Use Serverless:

  • When you need persistent state or long-running processes
  • If cold-start latency is unacceptable (e.g., real-time trading)
  • If vendor lock-in or observability limitations are a concern
  • For heavy-duty compute tasks better handled in long-lived VMs or containers

Real-World Example:

A contact form on your website uses a serverless function to send emails via an API. It only runs when a user submits the form — saving you infrastructure cost and scaling to handle spikes without effort.

FAQ

Does serverless actually mean no servers?
Nope — there are still servers involved, but they’re abstracted away. The term 'serverless' just means you don’t manage or see them.
Can I run full apps in serverless?
Yes, especially if you design your app as a set of functions or APIs. You can also combine serverless with static site hosting for full-stack experiences.
Is serverless cheaper than using VMs?
It depends on your usage. Serverless is cost-effective for low or spiky workloads, but can be more expensive for consistently high traffic.
What are cold starts?
A cold start is the initial delay when a serverless platform has to spin up your function from scratch. It adds latency, especially if the function hasn’t been called recently.
What languages are supported?
Most major serverless platforms support JavaScript (Node.js), Python, Go, Java, Ruby, and more. Some even support WebAssembly.

Related Stuff

Enjoyed this explanation? Share it!