13
votes

I've observed an abnormal (well, in my POV) feature, where when I setup SQS to trigger a Lambda, when new messages arrive, lambdas get triggered with more than 1 record/message inside its event body.

Full setup is S3 (PutObjectEvent) -> SNS topic -> SQS -> Lambda.

The abnormal behaviour is that for example, let's say I put 15 objects inside S3, which then forwards an event to SNS per each object, which then I can observe, SQS gets populated with 15 messages. However, when Lambdas start triggering, out of those 15 messages, only 11 Lambdas trigger, some of them containing more than 1 record/message inside its event body.

I've scoured the AWS documentation, but haven't found a concrete answer. Please note, these Lambdas do NOT poll SQS or fail or keep retrying. They execute perfectly fine, its just that inspected event body shows more than 1 record inside of it.

1

1 Answers

23
votes

Look at the sample event data for an SQS Lambda message here. The message is an array of records, which directly implies that there may be more than one SQS record in the message.

The documentation on SQS Lambda integration also clearly states that the Batch Size setting controls how many records a Lambda function may receive from SQS in a single call, with the default being 10. If you only want your Lambda functions to receive one message at a time you need to modify the Batch Size setting to be 1.