Date :- Sept 11, 2023 Day :- Monday
When triggering AWS Lambda functions from an event source like Amazon SQS, the batch size parameter can significantly impact how Lambda autoscales your functions.
Image via Unsplash
Batch size refers to the maximum number of messages that Lambda will retrieve from the queue and pass to your function as a single invoke request.
Image via Unsplash
A larger batch size means fewer invokes and thus fewer Lambda scaling events. This can reduce costs and latency compared to invoking Lambda for each message.
Image via Unsplash
However, each Lambda function invocation has some overhead for initializing a new execution environment.
Image via Unsplash
A good batch size aims for a balance between utilizing Lambda’s parallel processing and avoiding excessive initialization overhead.
Image via Unsplash
To compensate, you can configure a higher maximum scaling limit for your function if you’re using a large batch size.
Image via Unsplash
Reduce costs by minimizing the number of invoke
– Improve latency by amortizing initialization overhead across multiple message
it can also limit autoscaling if you don’t adjust the maximum scaling limit to match your batch size.
Image via Unsplash