Handling Failures Across Lambda Invocation Models
This lesson explains how the way a function is invoked decides who waits for the result, who retries failures and where failed events end up.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish synchronous, asynchronous and event source mapping invocations.
- Explain how destinations and dead-letter queues capture failed events.
- Identify common Lambda triggers.
Invocation types
Lambda functions are invoked in three ways, and the invocation type decides who handles failures. In a synchronous invocation, used by API Gateway, ALBs, function URLs and direct SDK calls, the caller waits for the result. If the function fails, the error goes back to the caller, which decides whether to retry.
In an asynchronous invocation, used by S3, SNS and EventBridge, Lambda places the event on an internal queue and returns at once. If the function fails, Lambda retries it twice, and events that still fail can be sent to an on-failure destination or dead-letter queue. With an event source mapping, used for SQS, Kinesis, DynamoDB Streams and Amazon MSK, Lambda polls the source and invokes the function with batches of records; a failed batch is retried, and failed SQS messages return to the queue. The following table summarises the three types.
| Type | Sources | Behaviour on failure |
|---|---|---|
| Synchronous | API Gateway, ALB, function URLs, SDK | The caller receives the error and decides whether to retry |
| Asynchronous | S3, SNS, EventBridge | Queued and retried twice, then sent to an on-failure destination or dead-letter queue |
| Event source mapping | SQS, Kinesis, DynamoDB Streams, Amazon MSK | Lambda polls and retries the batch; failed SQS messages return to the queue |
The following diagram shows each invocation type and its failure path.

How is it invoked?
Capturing failures
An event that fails repeatedly should be captured rather than lost or retried for ever, and the mechanism depends on the trigger. For asynchronous triggers, an on-failure destination, an SQS queue, SNS topic, Lambda function, EventBridge bus or S3 bucket, receives events that still fail after Lambda's retries, together with the error details, so they can be inspected and reprocessed.
For SQS, failures are captured by a dead-letter queue on the source queue, which receives messages after a set number of failed receives. Partial batch responses let the function report only the messages that failed, so one bad message does not cause the whole batch to be retried. For Kinesis and DynamoDB Streams, a failing batch blocks its shard, so bisecting the batch on error, limiting retries and sending details of skipped records to an on-failure destination keep one bad record from stopping processing. The following table summarises the mechanisms.
| Trigger type | Capture failures with |
|---|---|
| Asynchronous (S3, SNS, EventBridge) | On-failure destinations (SQS, SNS, Lambda, EventBridge, S3) after retries, including error details |
| SQS | A DLQ on the source queue, plus partial batch responses so one bad message does not retry the batch |
| Kinesis and DynamoDB Streams | Bisect on error, a retry limit and an on-failure destination, so one bad record does not block the shard |
Capturing failed events
Common triggers
API Gateway, function URLs, ALBs, S3 notifications, DynamoDB Streams, Kinesis, SQS, SNS, EventBridge rules and schedules, Cognito, CloudFront (Lambda@Edge) and Step Functions. Because every model can deliver an event more than once, handlers should be idempotent.
Where did the failed events go?
The destination of a failed Lambda event depends on the invocation model of its trigger. The following table identifies where failed events end up for several triggers.
| Trigger | Invocation model | Failed events end up |
|---|---|---|
| API Gateway | Synchronous | Returned to the client as an error |
| S3 upload notification | Asynchronous | On-failure destination after two retries, or lost if none is set |
| SQS queue | Event source mapping | The queue's dead-letter queue after maxReceiveCount attempts |
| Kinesis stream | Event source mapping | An on-failure destination once retries or record age are exhausted |
A team that lost failed image-processing events adds an on-failure destination to the S3-triggered function, so every failure is kept with its error details for reprocessing.
What is an event source mapping?
Show answer
A Lambda resource that polls a queue or stream, such as SQS, Kinesis or DynamoDB Streams, and invokes the function with batches of records.
Exam Tips
Remember for the exam
- To capture events that failed after asynchronous retries, use a Lambda on-failure destination.
- To run a function on a schedule, use EventBridge Scheduler or a scheduled rule.
- To retry only the failed messages in an SQS batch, use partial batch responses.
- Lambda handlers should be idempotent, because events can be delivered more than once.