Serverless (FaaS)
An event-driven execution model (Function-as-a-Service) that runs code on demand without managing servers, scaling automatically from zero and billing only for actual execution time
Table of Contents
Structure Diagram
Persistent hosts · Steady load
- BillingPay for idle capacity 24/7
- LatencyAlways warm; consistent p99
- Ops OverheadManage patching & cluster scaling
Event-driven · Scale-to-zero
- BillingPay-per-invocation & millisecond
- LatencyCold start spikes after idle periods
- Ops OverheadZero server ops; instant burst scale
What is Serverless (FaaS)?
An event-driven execution model (Function-as-a-Service) that runs code on demand without managing servers, scaling automatically from zero and billing only for actual execution time. It is a core concept in Containers & Orchestration within Cloud / DevOps.
Core Principles
Serverless Function-as-a-Service (FaaS) lets developers deploy small units of business logic without provisioning, patching, or sizing servers. The cloud platform executes functions strictly in response to events—HTTP calls, file uploads, queue messages, or schedules—and bills down to the millisecond of compute used.
When idle, FaaS automatically scales to zero (zero idle spend); when traffic surges, it spins up hundreds or thousands of concurrent sandboxes automatically.
Practical Takeaways
- Know when FaaS wins—and when containers win: FaaS shines for spiky APIs, webhook handlers, media processing, and async jobs. For steady 24/7 high-throughput workloads or long-running processes (>15 min), always-on containers are typically cheaper and more predictable.
- Protect relational databases from connection spikes: Hundreds of concurrent Lambda invocations can exhaust RDB connection pools instantly. Route traffic through a managed proxy (AWS RDS Proxy, PgBouncer) or HTTP-native data stores.
- Design idempotent handlers: Event sources (SQS, S3, EventBridge) guarantee at-least-once delivery, meaning duplicate triggers will happen; guard mutations with idempotency keys.
Notable Examples
- AWS Lambda: Powers event-driven media pipelines, API Gateway backends, and scheduled cloud automation.
- Google Cloud Run & Azure Functions: Combines container portability with scale-to-zero serverless billing.
- Vercel Functions & Cloudflare Workers: Runs API routes and edge logic seamlessly alongside modern web frontends.