Posted On: Apr 12, 2021

Amazon Lambda now allows customers using Amazon Simple Queue Service (Amazon SQS) as an event source in the Amazon Web Services China (Beijing) region, operated by Sinnet, and the Amazon Web Services China (Ningxia) region, operated by NWCD, to define a wait period, called MaximumBatchingWindowInSeconds, to allow messages to accumulate in their SQS queue before invoking a Lambda function. In addition to Batch Size, this is a second option to send records in batches, to reduce the number of Lambda invokes. This option is ideal for workloads that are not time-sensitive, and can choose to wait to optimize cost. 

Previously, Lambda functions polling from an SQS queue would send messages in batches of up to 10 before invoking the function. Now, customers can also define a time window that Lambda should wait to poll messages from their SQS queue before invoking their function. Lambda will wait for up to 300 seconds to poll messages from the SQS queue. When a batch window is defined, Lambda will return up to 10,000 messages, as long as the payload size remains 6MB or less.

To get started, when creating a new Lambda function or updating an existing function with SQS as an event source, customers can set the MaximumBatchingWindowInSeconds field to any value between 0 and 300 seconds on the Amazon Web Service Management Console, the Amazon CLI, Amazon SAM or Amazon SDK for Lambda. This feature requires no additional charge to use. To learn more about setting and utilizing MaximumBatchingWindowInSeconds for Lambda functions triggered by SQS, read the Lambda Developer Guide.