简体   繁体   中英

Batching trigger Lambda on DynamoDB

I'm having a table as below

Key                                 | Value
---------------------------------------------------
Client_123_UNIQUE_ID                | s3://abc.txt
Client_123_UNIQUE_ID                | s3://xyz.txt
Client_456_UNIQUE_ID                | s3://qaz.txt              
Client_456_UNIQUE_ID                | s3://qwe.txt
Client_789_UNIQUE_ID                | s3://asd.txt
Client_789_UNIQUE_ID                | s3://zxc.txt

The data will be inserted consistently to this table from a AWS Lambda function. (maybe millions items)

I have an use case which I need to have a trigger when there is 100 items available in the table to perform some batch processing. In other mean, as soon as we have 100 new items created in this table, I would like to have a trigger to Lambda function to perform a batch processing on 100 items.

When I research, it seems DynamoDB Stream can support Batch but I'm not pretty clear based on documentation.

Lambda reads records in batches and invokes your function to process records from the batch.

Lambda polls shards in your DynamoDB Streams stream for records at a base rate of 4 times per second. When records are available, Lambda invokes your function and waits for the result. If processing succeeds, Lambda resumes polling until it receives more records.

If your function returns an error, Lambda retries the batch until processing succeeds or the data expires. Until the issue is resolved, no data in the shard is processed. Handle any record processing errors in your code to avoid stalled shards and potential data loss.

Could you please help me to clarify documentation or advice me the approach which we use DynamoDB Stream is correct one for this use case?

If I'm explaining my question is not good enough, please put comments so I can clarify more.

You can set the BatchSize when declaring the mapping between the stream and Lambda. The max size is 1000 items.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM