You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing performance of reference solution I've noticed a 200-300ms latency caused by initialization of boto3 client/resource inside handler functions, for example:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
When testing performance of reference solution I've noticed a 200-300ms latency caused by initialization of boto3 client/resource inside handler functions, for example:
https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/blob/main/server/ProductService/product_service_dal.py
The same approach (and latency) is visible in all other functions using assumed_role credentials.
Following AWS documentation/best-practices, the resource/client initialization should be done outside handler (ref. https://docs.aws.amazon.com/lambda/latest/operatorguide/static-initialization.html), while there is no information how to tell client to use assume_role credentials in such case.
Is it possible to optimize and move boto3 client/resource initialization outside handler in such scenario or optimize the code in different way?
Beta Was this translation helpful? Give feedback.
All reactions