Asynchronous Invocation in AWS Lambda

Instruction: Explain asynchronous invocation in AWS Lambda and when it should be used.

Context: This question examines the candidate's understanding of asynchronous invocation in AWS Lambda, its benefits, handling of retries and failures, and appropriate use cases.

Updated

Official answer

With a direct asynchronous invocation, Lambda accepts an event into its internal queue and returns an acceptance response rather than the handler's result. Acceptance does not mean the business task completed. Use this for independent background work, with a durable job/result record when callers need completion status.

By default, a function/runtime error causes two additional attempts. Throttling and system errors use a different queue retry policy, with backoff for up to six hours by default. Configure maximum event age and retry attempts according to the task; events can expire or exhaust retries. Duplicate delivery is possible even without a function error, so make side effects idempotent.

Configure and test an on-failure destination or dead-letter queue as appropriate. Check permission and delivery failures for that capture path. An on-failure invocation record and a DLQ event payload are different formats. Define who investigates, how to reconcile uncertain side effects and how replay avoids duplicates.

Monitor event age, dropped events, failures and completion rate. Do not apply these asynchronous settings to SQS or stream event source mappings, which have source-specific batch and retry behavior. For longer workflows, use a suitable orchestrator or worker rather than assuming queueing removes Lambda's execution limits.

Asynchronous invocation, error and retry policies

Related Questions