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.