cloudpatterns.appClassroomKatasWhiteboardBlog
Z4 · Operations & Cost

Serverless vs always-on

Serverless vs always-on

Bronze

A serverless function is billed per call and for the memory it holds while it runs, so with no traffic it costs nothing. A server is billed every hour it exists, busy or not. At low or bursty traffic the function wins easily; at steady high traffic the per-call price adds up, and there is a request rate above which one always-on server is cheaper. The function's other costs show up as behaviour — after a quiet spell the first calls wait for a cold start, too many calls at once get throttled, and a call that hangs until its timeout is billed for the full time. Keeping functions warm removes cold starts, but brings back a bill for idle time.

Use when
Traffic with long idle stretches or sharp, rare bursts · Event-driven jobs — a photo upload that triggers a resize, a nightly report · A new feature whose traffic is unknown — pay nothing until it is used
Avoid when
A steady, high request rate around the clock — an always-on server is cheaper · Latency-critical paths that can't afford a cold start, unless you pay to keep instances warm · Long-running work beyond the platform's time limit
Trade-offs
Nothing billed while idle, but a higher price per unit of work once busy · No servers to size or patch, but cold starts, concurrency limits and time limits to design around · Keeping instances warm fixes cold starts and brings back a fixed bill · A mix — a server for the steady base, functions for bursts and events — is often cheapest, at the cost of running two models
Requires
Autoscale economics
3 objectives · 11 misconceptions
  • predict Predict the request rate at which a function's monthly bill crosses an always-on server's, from the price per call, the duration, the memory and the server's hourly rate.
  • explain Explain why a function slows down after a quiet spell, fails when too many calls arrive at once, and costs more when a call hangs until its timeout.
  • choose Choose a function, an always-on server or a mix for a workload from its traffic shape — idle stretches, bursts or a steady high rate — and its latency needs.
  • Not true: Serverless is always cheaper than running a server.
  • Not true: Serverless is always more expensive than a server once you have real traffic.
  • Not true: A function is billed only while it uses CPU, so time spent waiting for a database is free.
  • Not true: Serverless functions always respond at the same speed.
  • Not true: The busier a function is, the more of its calls wait for a cold start.
  • Not true: Keeping functions warm to avoid cold starts costs nothing extra.
  • Not true: Serverless scales without limit, so it can never turn requests away.
  • Not true: A function that times out costs nothing, because it failed.
  • Not true: A function's concurrency is the same as its requests per second.
  • Not true: There is one break-even rate between serverless and servers that holds for every app.
  • Not true: A function can run for as long as the work takes.

Learn

Serverless vs always-onMembers~14 min

Practice

No katas practice this yet.

Check

Station test-out80% to pass

Neighborhood

Serverless vs always-on
unlocksnothing yet
On linesCost Line

Progress is saved on this device