5 exercises on serverless architecture vocabulary.
0 / 5 completed
1 / 5
What is a cold start in AWS Lambda?
Cold start: Lambda execution environment lifecycle: Init (allocate micro-VM, download package, start runtime, run global code) → Invoke (call handler) → Shutdown (after idle timeout). Cold starts add 100ms-3s depending on runtime and package size. Java/JVM runtimes are the worst (heavy startup). Node.js/Python are fastest. Mitigations: provisioned concurrency (pre-warmed environments), smaller packages (tree-shaking), move init code outside the handler to cache across warm invocations.
2 / 5
What is the difference between synchronous and asynchronous Lambda invocation?
Synchronous: caller waits for response. Error propagates to caller — the caller must implement retries. Triggers: API Gateway, ALB, SDK direct invoke, Lambda Function URL. Asynchronous: Lambda queues the event internally, returns 202. Retries: 2 automatic retries on failure. After retries exhausted: DLQ (SQS/SNS) or Lambda Destination. Triggers: S3, SNS, EventBridge. Polling (event source mapping): Lambda polls the source. Triggers: SQS, Kinesis, DynamoDB Streams. Failed SQS batches go to DLQ.
3 / 5
What does reserved concurrency do in Lambda?
Reserved concurrency: carves N units from the account pool (default 1,000/region). Dual effect: (1) guarantees at least N concurrent executions for this function; (2) caps the function at N — throttles excess requests with 429. Setting reserved=0 disables the function. No extra cost. Provisioned concurrency (different): pre-initializes N environments, eliminating cold starts for up to N concurrent requests. Has cost even when idle. Combine: reserve=100, provision=20 means 100 maximum, 20 always warm.
4 / 5
What is the fan-out pattern in serverless architectures?
Fan-out: one event triggers multiple parallel downstream processes. Implementation: Lambda → SNS topic → multiple SQS queues (each consumed by a different Lambda). Or Lambda → EventBridge → content-based routing to different targets. Benefits: parallel processing (inventory check, fraud detection, and notification all run simultaneously), decoupling, independent scaling of each downstream process. Step Functions Map state: parallel branches in a workflow — a managed fan-out with built-in error handling and state tracking.
5 / 5
Why must serverless functions be stateless?
Stateless design: each invocation should be self-contained. In-memory data MAY persist within the same environment across sequential invocations on the same container (used for connection caching). But: Lambda may spin up a new environment at any time; concurrent invocations each have their own environment. State belongs externally: DynamoDB (application state), S3 (files/objects), ElastiCache (caching), SQS (work queues), Step Functions (workflow state). /tmp: 512MB–10GB ephemeral — reliable within one environment lifetime, not shared.