Book a free call

What Is Serverless Architecture, and When Should You Use It?

Serverless architecture runs your code on managed cloud infrastructure that scales automatically and bills per request, so you manage no servers. Here is how it works and when it fits.

Hertiv engineering teamReviewed by a senior engineer
5 min read
What Is Serverless Architecture, and When Should You Use It?
On this page

Short answer

Serverless architecture is a cloud model where the provider runs and scales your code on demand, and you pay only for what executes. You deploy functions or managed services, not servers, and the platform handles capacity, patching and availability.

What is serverless architecture?

Serverless architecture is a way of building software where the cloud provider runs your code in response to events, scales it automatically, and bills you only for the compute you consume. There are still servers, but your team does not provision, patch or size them.

Three ideas define it. First, no server management: you upload a function or configure a managed service, and the provider handles capacity and availability. Second, event-driven execution: code runs when an HTTP request, a queue message, a file upload or a schedule triggers it. Third, pay-per-use billing: you are charged for requests and execution time rather than for idle virtual machines.

Two common forms are Function-as-a-Service, where you deploy individual functions such as AWS Lambda, Azure Functions or Google Cloud Functions, and managed backend services such as hosted queues, object storage, authentication and databases that scale without your intervention.

Example (hypothetical): an image upload triggers a function that resizes the file and writes it to storage. If the service gets 10 uploads one hour and 10,000 the next, the same code handles both without any capacity planning from you.

How does serverless actually work under the hood?

The provider keeps a pool of execution environments and assigns your code to one when an event arrives. If no warm environment is available, it starts a new one, which introduces a delay known as a cold start.

The request path usually looks like this: an API gateway or event source receives the trigger, routes it to a function, the function runs with a time limit, then the environment is reused or recycled. State is not kept between invocations by design, so anything you need to remember goes into a database, cache or object store.

This model changes how you design. Functions should be small, idempotent and stateless. Long-running jobs, large in-memory workloads and persistent connections often need a different pattern, such as containers or a queue that breaks work into chunks.

Serverless vs containers vs virtual machines

The three models differ mainly in who manages the runtime and how you pay. Serverless shifts operations to the provider and bills per use; containers give you more control with a shared operating model; virtual machines give you full control at the cost of managing everything.

Model Who manages the OS Scaling Billing Best for
Serverless functions Provider Automatic, per request Per request and duration Event-driven, spiky or low-volume APIs
Containers You, partly Manual or orchestrated Per running instance Steady services, custom runtimes
Virtual machines You Manual Per running instance Legacy software, full control

A common arrangement is mixed: serverless for glue and event handling, containers for the core service, and managed databases for state. The decision is less about ideology and more about traffic shape, team skills and operational budget.

Where serverless fits well

Serverless is strongest where traffic is uneven, work is event-driven, and the team would rather not run infrastructure. It removes a category of operational work and lets a small team ship.

Good fits include:

  • APIs with unpredictable or low traffic, where paying for idle servers is waste.
  • Event processing: file uploads, webhooks, queue consumers, scheduled jobs.
  • Glue code between services, such as transforming data or calling a third-party API.
  • Prototypes and internal tools that need to be live quickly.
  • Background tasks that are short and can be retried safely.

If you are building data pipelines on top of these events, the patterns overlap with data engineering services, where ingestion and transformation often run as managed, event-driven steps.

Where serverless causes problems

Serverless becomes awkward when workloads are steady, long-running or latency-sensitive. The constraints are real and worth planning around.

Watch out for these cases:

  • Cold starts on latency-critical paths, especially with large dependencies.
  • Execution time limits that rule out long batch jobs in a single function.
  • Steady, high-volume traffic, where per-request pricing can exceed reserved capacity.
  • Stateful or connection-heavy workloads, such as long-lived database connections.
  • Local development and debugging, which need extra tooling to mirror the cloud.
  • Vendor lock-in through proprietary event sources and managed services.

None of these are blockers on their own, but several together usually point to containers or a hybrid design. A short architecture review before committing saves rework later; our software engineering services team does this regularly.

How to adopt serverless in practice

Start with a bounded workload, measure it, then expand. The goal is to learn where the model fits your traffic and team before it becomes the default.

  1. Pick one event-driven workload with clear inputs and outputs, such as a webhook handler or an upload processor.
  2. Define the contract: trigger, payload, timeout, retry behaviour and idempotency key.
  3. Set budgets and alarms for invocations, duration and errors before launch.
  4. Add structured logging and tracing from the first deploy, since you cannot inspect a server.
  5. Load test with realistic cold-start conditions, not just warm runs.
  6. Review cost and latency after a month, then decide whether to expand or move the workload.

Common mistakes

Most serverless problems come from treating functions like small servers. They are not; they are short-lived, stateless units with hard limits.

  • Holding state in memory between invocations and assuming it persists.
  • Building one large function that does everything instead of small, focused handlers.
  • Ignoring retries and idempotency, which leads to duplicate writes.
  • Skipping observability and discovering failures only from user reports.
  • Pricing the model on a demo instead of realistic traffic and duration.
  • Assuming serverless removes security work; identity, secrets and input validation remain yours.

Security is a frequent gap: every event source is an entry point. Our cybersecurity services cover identity, secrets management and review for serverless and hybrid systems.

Key takeaways

  • You write functions and events, not servers; the provider handles scaling and uptime.
  • Billing moves from idle capacity to per-request and per-duration metering.
  • Cold starts, execution time limits and state make it a poor fit for some workloads.
  • It pairs well with managed queues, storage and databases for event-driven systems.
  • Cost can drop for spiky traffic and rise for steady, heavy compute.
  • Local testing and observability need deliberate setup, not defaults.

Frequently asked questions

Is serverless the same as Function-as-a-Service?

Not exactly. Function-as-a-Service is one form of serverless, where you deploy individual functions. Serverless also covers managed queues, storage, databases and authentication that scale without you managing servers. FaaS is the most visible part, but the model is broader.

Does serverless cost less than running servers?

It depends on traffic shape. Spiky or low-volume workloads often cost less because you pay only for use. Steady, high-volume workloads can cost more than reserved capacity. Model both against realistic request and duration figures before deciding.

What is a cold start?

A cold start is the delay when the provider must create a new execution environment before running your function. It is most noticeable on latency-sensitive paths and with large dependencies. Keeping functions small and dependencies lean reduces it, though it cannot be removed entirely.

Can serverless handle long-running jobs?

Only indirectly. Functions have execution time limits, so long jobs are usually split into steps or handed to a queue, container or workflow service. If most of your work is long-running, containers or batch services are usually a better fit.

Is serverless secure?

The provider secures the underlying infrastructure, but your code, identity, secrets and input validation remain your responsibility. Each event source is an entry point. Apply least privilege, rotate secrets and review permissions as part of the design.

When should we avoid serverless?

Avoid it for steady, high-throughput services, persistent connections, large in-memory workloads and strict latency budgets where cold starts are unacceptable. Hybrid designs, with containers for the core and serverless for events, often fit better than choosing one model everywhere.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: software products in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning a serverless or hybrid architecture and want a second opinion?

A senior engineer replies within one business day. Or see our Cloud Services service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call