What is Serverless Architecture?

Last updated: July 2026

Serverless architecture is a cloud execution model where the provider runs your code on demand, so you never provision or manage servers. Servers still exist — you just stop renting, patching, and scaling them. You deploy functions; the platform allocates compute when an event arrives and bills you only for what runs.

Key takeaways

QuestionAnswer
What it isCode that runs in provider-managed, on-demand compute — no server provisioning
Problem it solvesCapacity planning, idle-server costs, and infrastructure operations
Billing modelPer request + per GB-second of execution; scales to zero when idle
Watch out forCold starts, execution time limits, provider lock-in
Back4app equivalentCloud Code functions — deploy code, Back4app runs it

The problem it solves

With a traditional deployment you rent capacity ahead of demand: size the instance, configure autoscaling, pay for idle time, patch the OS. Get it wrong in one direction and you burn money; in the other, you drop requests at your traffic peak.

In a serverless model that entire loop disappears. You write a function, and scaling from zero to thousands of concurrent executions is the provider’s job. This is all the backend code needed to compute a movie’s average rating server-side:

// cloud/main.js — a Back4app Cloud Code function
Parse.Cloud.define('averageStars', async (request) => {
  const query = new Parse.Query('Review');
  query.equalTo('movie', request.params.movie);
  const reviews = await query.find();
  const sum = reviews.reduce((acc, r) => acc + r.get('stars'), 0);
  return sum / reviews.length;
});

There is no Express app around it, no Dockerfile, no load balancer. The function is the unit of deployment.

Calling it from any client

Every client SDK invokes the same function by name — the transport, auth, and scaling are handled by the platform:

// JavaScript / Node.js — Back4app JS SDK
const params = { movie: 'Inception' };
const rating = await Parse.Cloud.run('averageStars', params);
console.log(`Average rating: ${rating}`);

How a serverless request flows

Serverless request flowA client calls a managed endpoint; the platform runs the function on a warm instance or provisions one in a cold start, reads the managed database, returns the response, and scales to zero after idle.

yes

no

after idle period

Client app

Managed HTTPS endpoint

Warm instance
available?

Execute function

Cold start:
provision runtime

Managed database

Response to client

Scale to zero
cost: $0

A client calls a managed endpoint; the platform runs the function on a warm instance or provisions one in a cold start, reads the managed database, returns the response, and scales to zero after idle.

The branch to watch is the cold start. When no warm instance exists, the platform must provision a runtime before executing your code — anywhere from a few milliseconds to several seconds depending on language, code size, and dependencies. In production it affects only a small fraction of requests, since a steadily invoked function keeps reusing warm instances — negligible for most APIs, but real for latency-critical paths, and a reason edge functions and warm-up strategies exist.

Serverless vs. containers vs. traditional servers

DimensionServerlessContainers (Kubernetes)Traditional VMs
Unit you deployFunctionContainer imageMachine image
ScalingAutomatic, per request, to zeroAutomatic, but you configure and pay for the clusterManual or autoscaling groups
Idle cost$0Cluster keeps runningInstance keeps running
Cold startsYes (ms–seconds)No (pods stay warm)No
Long-running processesLimited by execution timeoutsYesYes
Ops burdenNoneSignificant (cluster, upgrades, capacity)Highest (OS, patching, HA)
Best forEvent-driven, spiky, or unpredictable loadSustained load, custom runtimesLegacy systems, full control

FaaS and BaaS: the two halves of serverless

“Serverless” covers two complementary models, a distinction Mike Roberts’ canonical article on martinfowler.com formalized. The split has a birthday: commercial event-triggered compute launched in 2014, and within two years serverless went from research idea to production default for event-driven work — which is why the vocabulary still feels newer than the ideas underneath it. FaaS (Functions-as-a-Service) means you still write server-side logic, but it runs in stateless, event-triggered, fully managed compute — the “cloud functions” model. BaaS (Backend-as-a-Service) goes further: the database, authentication, file storage, and APIs are themselves consumed as managed services, so most backend code you would have written disappears entirely.

Most real applications need both — functions for custom logic, managed services for everything else. That combination is exactly what a BaaS platform packages. For a deep dive into that half of the model, read our complete guide to Backend as a Service.

Common serverless use cases

  • APIs and mobile backends. The dominant case: request-driven traffic that idles at night and spikes at launch — exactly the shape pay-per-execution pricing rewards.
  • Event and data processing. Resize an image on upload, validate a record on save, sync a change to a third-party system — short-lived reactions to events.
  • Scheduled jobs. Nightly reports, cleanup tasks, and recurring syncs run as cron-triggered functions with no server waiting around between runs.
  • Real-time features. Chat, notifications, and live dashboards pair serverless functions with managed real-time infrastructure instead of hand-rolled WebSocket servers.
  • MVPs and prototypes. When validating an idea, spending zero time on infrastructure is the entire point — deploy a function, get a URL, ship.
  • AI agents and webhooks. Glue code between LLMs, payment providers, and SaaS APIs is naturally event-driven and short-lived — a perfect serverless fit.

Should you go serverless? A decision matrix

Choose serverless when…Choose always-on servers when…
Traffic is spiky, unpredictable, or low-volumeTraffic is sustained and high-volume (always-on is cheaper)
You need to launch fast with a small teamYou run long-lived processes that exceed function timeouts
Standard building blocks (auth, CRUD, storage) cover most needsYou need custom runtimes, GPUs, or specialized hardware
You have no dedicated DevOps resourcesRegulations require full control of the infrastructure
Cost should track usage, starting at $0Sub-10-ms tail latency is non-negotiable on every request

On cost, concrete anchors help: serverless platforms bill per request plus compute time consumed (GB-seconds), with no upfront commitment — and Back4app’s free tier includes 25,000 API requests per month, enough to run a real MVP at $0 before any scaling decision is needed.

Limitations and trade-offs

  • Cold starts. The first invocation of an idle function pays a provisioning penalty (sub-100 ms to over a second). Mitigations: warm concurrency, smaller bundles, edge runtimes.
  • Execution time limits. Functions are built for short work; video encoding or hour-long batch jobs belong in containers or background job systems.
  • Harder debugging and observability. There is no server to SSH into. You depend on the platform’s logs, metrics, and tracing — evaluate them before committing.
  • Vendor lock-in. Functions written against proprietary APIs are expensive to move. Prefer platforms built on open source — Back4app’s Cloud Code runs on an open-source foundation you can self-host anytime.
  • Cost at sustained scale. Pay-per-execution is unbeatable at low and spiky volume but can exceed flat server pricing under constant heavy load. Re-run the math as traffic stabilizes.
  • Statelessness. Functions keep no memory between invocations; session and application state must live in a database or cache, which is a design constraint if you’re porting stateful code.

How Back4app implements serverless

Back4app is an open-source Backend-as-a-Service (BaaS) platform that combines a managed database, auto-generated REST and GraphQL APIs, authentication, file storage, and Cloud Code serverless functions. It gives you both halves in one platform. The FaaS half is Cloud Code: JavaScript functions like averageStars above that you deploy from the dashboard or CLI, plus database triggers and scheduled jobs — no gateway, IAM policies, or infrastructure to configure. The BaaS half comes provisioned with every Back4app app: the database, user authentication, file storage, and auto-generated REST and GraphQL APIs. And because Back4app builds on an open-source foundation, the functions you write are portable — you can self-host the same stack later, which removes the lock-in objection that hangs over provider-specific serverless platforms.

Frequently asked questions

Does serverless mean there are no servers?

No — servers still run your code. "Serverless" means the servers are invisible to you: the cloud provider owns, provisions, patches, and scales them. You deploy functions and the platform decides where and when they execute. From the developer's perspective there is nothing to size, restart, or maintain.

Is serverless cheaper than traditional servers?

For spiky or low-volume workloads, usually yes: you pay per request and per GB-second of execution, and the bill drops to zero while nothing runs. For sustained high-volume traffic, an always-on container or reserved instance is often cheaper, because per-invocation pricing at millions of steady requests can exceed a flat server fee. Model your real traffic curve before choosing.

What are the disadvantages of serverless architecture?

The main trade-offs are cold starts (typically under 100 ms up to over 1 second on the first invocation of an idle function), execution time limits, harder local debugging and observability, and potential vendor lock-in if your functions use provider-specific APIs. Platforms built on open source, like Back4app Cloud Code, mitigate the lock-in risk because you can self-host the same stack.

Should I use serverless or containers?

Choose serverless over Docker containers for event-driven, spiky, or unpredictable workloads and for small teams that do not want to operate infrastructure. Choose containers for long-running processes, custom runtimes, or sustained high-volume services where always-on capacity is cheaper. Many production systems combine both: serverless for APIs and event handlers, containers for steady background workloads.

Are cold starts still a problem?

Far less than they used to be. In production, cold starts affect only a small fraction of invocations — a steadily invoked function reuses warm instances for hundreds of thousands of calls — and typically last from a few milliseconds up to about a second depending on runtime and code size. For latency-critical paths you can mitigate them with warm concurrency, lighter dependencies, or edge functions. For typical APIs and mobile backends they are rarely noticeable.

What is the difference between FaaS and BaaS?

FaaS (Functions-as-a-Service) runs the server-side code you still write — stateless, event-triggered functions like Back4app Cloud Code. BaaS (Backend-as-a-Service) goes further: the database, authentication, file storage, and APIs are consumed as ready-made services, so most backend code disappears entirely. They are complementary halves of the serverless model, and most real applications use both.

When should you NOT use serverless?

Avoid serverless for long-running jobs that exceed execution time limits, workloads needing specialized hardware or custom runtimes, latency-critical systems that cannot tolerate any cold start, and sustained high-volume traffic where always-on servers are cheaper. Regulatory requirements for full infrastructure control can also rule it out.

What programming languages can serverless functions use?

It depends on the runtimes your platform provides — JavaScript/Node.js is the most universally supported, and most platforms add options like Python, Go, or Java. On Back4app, Cloud Code functions are written in JavaScript on a managed Node.js runtime, so the same language your web frontend uses runs your backend logic. Whatever the platform, your clients are unaffected: they call functions by name over HTTPS or an SDK.

Related terms

Compare with

Further reading

Ready to build your backend?

Start your project on Back4app in minutes — database, auth, APIs, and Cloud Code included. No credit card required.

Written and reviewed by Back4app Engineering, Back4app Engineering · Published 2026-07-15 · Updated 2026-07-16