Bookmarks

Serverless architecture

A code execution model in which the cloud provider allocates and releases compute resources for each event itself, and you pay only for the time the code actually runs.

Also: serverless computing, FaaS, Function as a Service

checked 8 Nov

All terms

“Serverless” does not mean “without servers”: the servers still exist, but the provider manages them. The developer uploads code and subscribes it to events – an HTTP request, a queue message, a file in storage – while the provider starts, scales and maintains it.

How it works

The main form of serverless is functions, FaaS: AWS Lambda, Azure Functions, Google Cloud Run functions. Managed databases and storage that are invoked and billed the same way – by actual usage – are also considered serverless.

PartyResponsible for
Developerthe function code: logic for handling a single event, dependencies, memory and time limits
Providerservers, starting and reusing execution environments, scaling, OS patches
Triggerthe event source: HTTP gateway, queue, scheduler, change in storage

The provider keeps a pool of ready execution environments. If an environment for the function is already up, the call is fast (a “warm start”); if not, the environment is created from scratch, which is a cold start: it adds latency and is billed. According to the AWS Lambda documentation, cold starts affect less than 1% of invocations and last from under 100 ms to over a second; for predictable latency, environments can be kept pre-warmed (provisioned concurrency).

Billing and scaling

  • you pay for invocations and running time: in AWS Lambda, the number of requests plus gigabyte-seconds (memory × time); when idle, zero
  • scaling from zero: with no events there are no instances at all, and under a spike the provider starts them itself
  • limits depend on the provider: in AWS Lambda, memory from 128 MB to 10,240 MB (in 1 MB steps; at 1,769 MB this is one vCPU), an invocation lasts up to 15 minutes by default
  • long tasks are not put into a single function – they are split into steps with a chain of invocations or an orchestrator

Example: thumbnails for uploaded images

A user puts a file into object storage – the provider invokes a function and passes it the address of the object. The function creates a 200×200 thumbnail and saves it next to the original. A nightly stream of 10,000 files is handled by parallel invocations, and during the day at zero load there is nothing to pay for.

Sources

the term is written from these pages

Verified 8 Nov

Not to be confused with

what it is mixed up with and how it differs

  • PaaSplatform as a service

    In PaaS, the application runs continuously and you pay for the allocated resources even when there is no traffic.

  • microservices

    Microservices are a way to split a system into services; serverless is a model for running and paying for code.

In depth in the references

where the topic is covered in detail