I am encountering a delay issue with a Lambda function triggered by a DynamoDB stream. Despite configuring the Lambda with Node.js 16.x, a timeout of 5 minutes, and 1536 memory allocation, the trigger takes over 5 minutes to initiate the Lambda execution.
How can I decrease this trigger time? I've attempted to increase Lambda memory and timeout settings, but it hasn't resolved the delay. Any suggestions or insights into optimizing the trigger time would be greatly appreciated.
Lambda settings:
NodeJs 16.x
5 minute timeout
1536 memory configuration
Your EventSourceMapping needs configured correctly, it's got nothing to do with your Lambda memory.
5 minutes is the default batch window time. What's happening is you're not meeting the default 100 items in the shard for it to invoke the function,so it's waiting for the batch window to trigger the function.
Batch size– The number of records to send to the function in each batch, up to 10,000. Lambda passes all of the records in the batch to the function in a single call, as long as the total size of the events doesn't exceed the payload limit for synchronous invocation (6 MB).Batch window– Specify the maximum amount of time to gather records before invoking the function, in seconds.My advice is to lower the value for both of these. Batch size should be low enough that you accumulate N amount of changes in Y time. Y being the time you deem reasonable to invoke the function.