Interview Prep/AWS/Containers and Serverless

How does Lambda process SQS messages and handle partial failures?

AdvancedConceptContainers and Serverless
Answer

The event source mapping polls the queue with long polling and invokes your function with a batch (up to 10, or 10,000 with a batching window). If the function throws, the whole batch returns to the queue after the visibility timeout, causing reprocessing of successes. Enable ReportBatchItemFailures and return the failed IDs.

{"batchItemFailures":[{"itemIdentifier":"msg-id-3"}]}

Set visibility timeout to at least 6x the function timeout, configure a DLQ with maxReceiveCount, and use MaximumConcurrency on the mapping to protect downstreams.

aws All AWS questions Roadmap: EKS, ECS & serverless on AWS

More on Containers and Serverless