Skip to content

Serverless Architecture

Serverless doesn’t mean there are no servers. It means you don’t have to think about them. You write functions, and the cloud provider (AWS Lambda, Cloudflare Workers) runs them on demand.


sequenceDiagram
participant Client as 📱 Client
participant Gateway as 🚪 API Gateway
participant Function as ⚡ Function (Lambda)
participant DB as 🗄️ Database
Client->>Gateway: HTTP Request
Gateway->>Function: Invoke function (cold start? 🔄)
Function->>DB: Query database
DB-->>Function: Results
Function-->>Gateway: Response
Gateway-->>Client: HTTP Response (200)

AspectServerlessTraditional Server
ProvisioningAuto (zero to N instantly)Manual (need to estimate capacity)
ScalingInvisible — scales per requestConfigurable — autoscaling groups
PricingPer-invocation + durationPer-hour server cost
Cold start❌ Can be slow (first invocation)✅ Always warm
TimeoutLimited (Lambda: 15 min max)Unlimited
StateStateless by defaultCan store in memory
Best forEvent-driven, sporadic trafficSustained, predictable load

Use CaseWhy Serverless?
Webhook handlersLow traffic, just needs to work
Image processingTriggered by upload, process then done
Cron jobsRun on schedule, no idle cost
Mobile/Web backendsSpiky traffic, unpredictable load
Event-driven tasksFile upload → process → notify

  • Cold starts — functions that haven’t run recently can take 1-2 seconds to start.
  • Vendor lock-in — your code is tied to AWS Lambda / Cloudflare Workers APIs.
  • Debugging harder — no SSH access, distributed tracing needed.
  • Cost at scale — at very high traffic, dedicated servers might be cheaper.
  • State — every request starts fresh. Use external storage (Redis, DB) for state.

  • Serverless = you write code, the cloud runs it. No servers to manage.
  • Great for sporadic traffic, webhooks, and event processing.
  • Watch out for cold starts and cost at very high volume.