What is the difference between synchronous and asynchronous Lambda invocations?
Answer
Synchronous invocations — the caller waits for the Lambda function to complete and returns the result directly. Examples: API Gateway, Application Load Balancer, Lambda-to-Lambda SDK calls (RequestResponse invocation type). Error handling: the caller receives the error response immediately. Timeout: limited by the caller (API Gateway max 29 seconds, even though Lambda max is 15 minutes). Asynchronous invocations — Lambda immediately acknowledges receipt and returns a 202; the function executes in the background. Examples: S3 event notifications, SNS, EventBridge, CloudWatch Events. Error handling: Lambda retries the function twice on failure with delays; after all retries, the failed event goes to the DLQ (if configured). The caller never sees the function's return value directly. Best for: long-running background tasks, fire-and-forget processing, event fan-out. Poll-based invocations (SQS, Kinesis, DynamoDB Streams) — Lambda polls the event source and processes messages in batches; Lambda handles retries based on the source's retry configuration.
Previous
How do you monitor and debug serverless functions?
Next
How do you manage secrets in serverless applications?
More Serverless Architecture Questions
View all →- Intermediate How do you reduce cold start latency in serverless functions?
- Intermediate What is AWS Step Functions and when would you use it?
- Intermediate How do you handle state in serverless applications?
- Intermediate What is the Serverless Framework and how does it work?
- Intermediate How do you implement authentication in a serverless API?