System Design Cases
Serverless Patterns: Lambda, Workers, Step Functions
Serverless patterns: FaaS (AWS Lambda + API Gateway + DynamoDB + Aurora via RDS Proxy), event-driven (S3 → SQS → Lambda batch with DLQ), Step Functions orchestrated saga (ChargeCard → ReserveInventory → Compensate Refund), EventBridge cron, Cloudflare Workers at the edge with KV + D1 + Durable Objects, Cloud Run container serverless. Covers cold start vs warm pool vs provisioned concurrency, RDS Proxy connection pooling, anti-pattern of Lambda + direct RDS connection storm. Includes ADR on serverless vs containers vs k8s cost/scale crossover.
Serverless patterns: delivery semantics before scale
Serverless removes server fleet management from the application team; it does not remove invocation types, retry policy, concurrency limits, durable state or data consistency. Draw the event source, queue, function, idempotency record, business store and failed-event destination as separate boundaries.
Invocation correctness
- A synchronous caller decides whether to retry after a timeout, when the function may have completed. Reuse a business idempotency key.
- Lambda asynchronous invocation and event-source mappings can deliver an event more than once. Consumers require an atomic claim and deterministic effects; object-store notifications are not a global exactly-once log.
- Bound retry age/count, configure redrive or failure destinations, and make replay an audited operation.
- Step Functions Standard and Express differ, and explicit task retries can repeat effects. “Workflow exactly once” is not permission to make payment or inventory APIs non-idempotent.
D1 consistency
D1 writes go to one primary. Read replicas update asynchronously. The Sessions API uses bookmarks to provide sequential consistency for the logical session; it is not blanket global strong consistency for arbitrary clients. Carry the bookmark across requests when read-your-writes matters.