How a Serverless Function Runs
You upload only code and say which event should run it. The platform finds a place to run it, starts more copies when events pile up, and drops them when nothing happens. Follow one function from event → execution environment → result, with AWS Lambda as the example. Google Cloud Run, Azure Functions and Knative on Kubernetes work along the same lines with different limits.
What you will learn
- Events from HTTP, queues and uploads all start the same function
- What a cold start does and why warm reuse is faster
- One request per environment, so concurrency means more environments
- Concurrency limits, 429 throttling and the timeout ceiling
- Retries deliver the same event twice, so handlers must be idempotent
- Pay per request and duration, and when a function is the wrong tool
VM, container on Kubernetes, or function?
| Virtual machine | Container on Kubernetes | Serverless function | |
|---|---|---|---|
| You manage | OS, runtime, app, scaling | Image, manifests, cluster (or a managed one) | Code and settings only |
| Unit of scaling | Whole VM (minutes) | Pod (seconds) | Execution environment per request (milliseconds to seconds) |
| Idle cost | Paid while running | Nodes paid while running | Near zero (scale to zero) |
| Run length | Unlimited | Unlimited | Capped (Lambda: 30 min) |
| State | Local disk persists | Volumes (PV) if needed | None between calls, use external stores |
| Good fit | Legacy apps, special OS needs | Steady services, many microservices | Bursty events, glue code, webhooks, file processing |
Knative brings the function model (scale to zero, scaling by concurrency) onto a Kubernetes cluster you run yourself.
Try it yourself
aws lambda invoke --function-name demo --cli-binary-format raw-in-base64-out \
--payload '{"id": 1}' out.json && cat out.json # Synchronous call
aws lambda get-function-configuration --function-name demo \
--query '[Runtime,MemorySize,Timeout]' # Settings that drive cost and limits
aws logs tail /aws/lambda/demo --since 10m # REPORT lines: Duration, Billed Duration, Init Duration
aws lambda get-account-settings --query 'AccountLimit.ConcurrentExecutions' # Account concurrency limit
aws lambda put-function-concurrency --function-name demo \
--reserved-concurrent-executions 50 # Reserve and cap concurrency for one function
aws lambda put-provisioned-concurrency-config --function-name demo \
--qualifier live --provisioned-concurrent-executions 5 # Keep 5 environments initialized (billed)
Check yourself
Further reading: What is AWS Lambda? · Lambda execution environment lifecycle · Lambda concurrency · Asynchronous invocation · Cloud Run concurrency · Knative Serving · Who Owns What (IaaS · PaaS · SaaS) · Until a Model First Starts (Cold Start)