- Newest
- Most votes
- Most comments
Hello, Matan Erez.
Here's what you can do to potentially reduce the processing time with a larger batch size:
Concurrency Settings: Consider adjusting the concurrency settings for your Lambda function. You can either increase the concurrency to handle more invocations in parallel or experiment with different batch sizes and batch window settings to find the optimal balance for your specific use case.
Throttle SQS Queue: If the SQS queue is a bottleneck, you may need to consider adjusting the SQS queue's configuration. For example, you can adjust the queue's visibility timeout, message retention period, and the number of inflight messages to better match the processing capacity of your Lambda function.
Asynchronous Processing: If it's feasible for your application, you might consider asynchronous processing with a fan-out pattern. In this approach, you use an SQS queue to collect incoming events and then trigger multiple Lambda functions to process the messages concurrently. Each Lambda function can handle a smaller batch size, which may lead to more predictable and faster processing times.
Best regards, Andrii
When you increase the batch size it means your function will receive more records. If it takes your function 3 seconds to process 10 records, it makes sense that it will take the function 20 seconds to handle 100 records.
Window size has nothing to do with processing time. It controls how long should the Lambda service wait for the batch to fill before invoking your function. If you set your batch window to 10 seconds and the batch size to 100, Lambda will wait up to 10 seconds, or 100 records, before invoking your function.
If you want to reduce the processing time of a large batch, you can use threads inside your function, each thread processing a subset of the records.
As previously mentioned, you increased the batch size from 10 to 100 which means you increased it to 10 times the original size. If it took 3 seconds to process 10 then each record takes approximately 300 milliseconds to process each record (10 * 300 ms = 3,000 ms = 3 seconds). Theoretically, it would now take 30 seconds to process 100 (100 * 300 ms = 30,000 ms = 30 seconds).
Relevant content
- Accepted Answerasked 3 months ago
- asked 2 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago