Advertisement
Advanced AWS, Amazon SQS (Simple Queue Service)

How does SQS integrate with Lambda for event driven message processing, including batching behavior?

Short answer

Lambda can be configured with an SQS queue as an event source, automatically polling the queue and invoking your function with a batch of messages whenever they become available, and you can configure batch size and batching window settings to control how many messages are…

Save AWS mock interview
Advertisement
AModel answer
Lambda can be configured with an SQS queue as an event source, automatically polling the queue and invoking your function with a batch of messages whenever they become available, and you can configure batch size and batching window settings to control how many messages are grouped into a single invocation, letting you balance between processing latency and the efficiency of handling multiple messages together in one function execution.
Example

aws lambda create-event-source-mapping --function-name processOrders --event-source-arn arn:aws:sqs:us-east-1:123456789012:OrderQueue --batch-size 10

Real-world example
An order processing pipeline configures its Lambda function to process up to ten SQS messages per invocation, reducing the number of Lambda invocations needed compared to processing one message at a time, while still keeping processing latency low.
Likely follow-ups
  • What happens if one message in a batch fails while others succeed?
  • How does Lambda concurrency scale with SQS queue depth?
Related topics