Architecture style
Serverless architecture
Code runs as functions in response to events, while the cloud handles servers, scaling and idle time. You pay for invocations, not for machines that wait.
How it works
You write a function (a handler), and the platform (AWS Lambda, Cloudflare Workers, Google Cloud Run) runs it on every event: an HTTP request, a file in storage, a message in a queue, a cron tick. No requests means no running copies and no bill for idle time.
Functions are usually surrounded by managed services: API Gateway at the edge, DynamoDB or Supabase for data, S3 for files, SQS for queues. So serverless is not only FaaS, it is an approach of «assembling the system from managed blocks».
Limits you need to know
Cold start: the first call after idle time spins up a new environment, which adds from tens of milliseconds (Workers on V8 isolates) to a second or more (Lambda on Java without SnapStart). For an API with a strict p99 target, you will feel it.
Execution limits: Lambda runs at most 15 minutes per invocation and has a default quota of 1,000 concurrent executions per region. A function keeps no state between calls, so PostgreSQL connections must be pooled through a proxy (RDS Proxy, PgBouncer), or a thousand functions will exhaust max_connections.
Money: when it is cheap and when it is not
Serverless works great for uneven load: processing uploaded videos in ShortLesson, payment provider webhooks, nightly reports, traffic spikes after a newsletter. Between spikes you pay close to nothing.
Under steady high load the pay per invocation model becomes more expensive than ordinary containers. In 2023 the Amazon Prime Video team moved a video quality monitoring service from Step Functions and Lambda into a single process on ECS and reported a 90% drop in infrastructure cost.
Debugging and vendor lock-in
Reproducing a chain of «S3 event, Lambda, SQS, another Lambda» locally is hard. Emulators (LocalStack, SAM CLI), structured logs and tracing via OpenTelemetry or X-Ray help.
Triggers, IAM policies and event formats are specific to each cloud, so moving is expensive. Keep business logic in plain modules and make the handler a thin adapter.
Pros
- Zero cost for idle time and automatic scaling to thousands of parallel calls.
- No OS patching, no server or autoscaling management.
- Fits event workloads naturally: files, webhooks, cron, queues.
- A fast start for a small team.
Cons
- Cold starts add latency to the first request.
- Limits on execution time, memory and concurrency.
- Under steady high load it is often more expensive than containers.
- Hard local debugging and strong provider lock-in.
When to choose it
- Load is spiky or unpredictable, with long quiet periods.
- Work is triggered by events: a file upload, a webhook, a queue message.
- A small team without DevOps wants to ship quickly.
- Each operation is short (seconds, not hours).
Where it is used
- Amazon Prime Video (2023): a video quality monitoring service moved from Lambda and Step Functions to a monolith on ECS, cutting costs by 90%.
Tools
- AWS LambdaAn AWS service that runs functions in response to events and bills only for execution time.
- Cloudflare WorkersA serverless platform on Cloudflare's edge: V8 isolate code starts almost instantly worldwide.
- Google Cloud RunManaged container hosting that autoscales to zero and bills per use.
- VercelA frontend platform from the creators of Next.js: Git deploys, a preview for every PR, serverless functions and edge.
- NetlifyA platform for sites and JAMstack: Git deploys, forms, serverless functions and a CDN.
- FirebaseA backend as a service from Google: Firestore, auth, hosting, Cloud Functions and push messaging.
- SupabaseAn open source Firebase alternative on PostgreSQL: database, auth, file storage, realtime and Edge Functions.
- Amazon DynamoDBA fully managed AWS key-value and document database with predictable latency and automatic scaling.
- Amazon SQSAmazon SQS is a fully managed message queue from AWS that scales automatically and needs no servers.
Related topics
Sources
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).