AWS Lambda Invocation Types
Instruction: Explain the different ways to invoke an AWS Lambda function and the use cases for each.
Updated
Official answer
The Invoke API has three invocation types:
- RequestResponse invokes synchronously and returns the function result or function-error information. A successful API status does not guarantee that the handler succeeded; inspect the response. This suits a caller that needs the result immediately.
- Event submits an asynchronous event. Acceptance means the event was queued, not that business processing completed. Observe completion or configure failure handling separately.
- DryRun checks request parameters and invocation permission without running the handler. It does not test the function's business logic or downstream access.
Services integrate through their own delivery contracts. API Gateway commonly invokes a handler for a synchronous request, while S3 notifications invoke asynchronously. With SQS, Kinesis or DynamoDB Streams, an event source mapping polls records and invokes the function with batches. A DynamoDB table write is not a direct asynchronous Invoke call to the function; the configured stream is the source.
Choose the mode according to latency, durability, batching and retry requirements. Caller retries, asynchronous Lambda retries and source redelivery differ. Use the source's event schema, authorization model and success/failure contract, and make side effects safe under duplicate delivery.