Description
Use case
I've been doing some benchmarking of using the lambda layer vs bundling the SDK using esbuild. There appears to be a noticeable performance penalty in using the lambda layer on coldstarts. I'm using dynamic import
and importing Tracer, Logger, Metrics and initializing each of them in my initialization. I'm also making calls to secrets manager in initialization so I've timed them and removed their impact from the normalized init duration. I'm seeing a repeatable impact of 100+ ms when using the layer.
init duration | secrets loading | normalized | lambda layer | delta | notes |
---|---|---|---|---|---|
849 | 121 | 728 | none | +0 ms | This is with bundling using esbuild |
1089 | 167 | 922 | 18 | +194 ms | This is Lambda layer 18 |
994 | 112 | 882 | 20 | +154 ms | This is Lambda layer 20 |
It's possible I've overlooked something, and I'll admit, my sample size is low but repeatable. This has more on the esbuild flags I'm using: https://speedrun.nobackspacecrew.com/blog/2023/09/23/optimizing-lambda-coldstarts.html
Solution/User Experience
If possible, conduct a similar benchmark and explore using esbuild or other techniques that could reduce the impact of using the layer. If there remains a performance penalty vs. bundling the SDK, document it.
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status