Reduce Powertools Cold Start Impact #1907
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @barreeeiroo - that's unusual, at most, AWS SDK would incur ~200ms for creating a SDK Client + TLS Handshake (Session creation), though I've seen north of 300 lately if using a newer SDK version. X-Ray SDK will add at worst 300-400ms (uses AWS SDK + some non-optimised path). This should be amortised by a warm start. Higher memory functions have a lower cold start because of the CPU Slicing Lambda does, so you have more room for cryptography operations AWS SDK and TLS require -- Lambda PowerTuning can be a pragmatic way to find what optimum looks like. Powertools being a thin wrapper, specially in Parameters, it'll only inherit what SDK and X-Ray does, and slow down on call stacks and control flows (~10-50ms at worst). That being said, we can always improve and we will stop at nothing to achieve it given the bandwidth. For actionable steps, would you be able to share a sample repo without sensitive data so we can try to reproduce? Please keep the same memory, runtime, AWS Region (round trip latency), settings you're using and such. Until then, I'd suggest using a mix of Tuna (cold start profiler), and CodeGuru or any line profiler like pybenchmark locally. There was a discussion in AWS SDK to ship compact models which would increase cold start by at least 50ms per client (decompress model at client creation) - your sample will help us track down dependencies, and make a PR to improve any non-optimal areas. Meanwhile, if you can tell us what your dependencies look like (I'll exclude PynamoDB to keep it simple), what your function memory setting and event source are, we can setup a POC on our side. PS: This week is tough, but also happy to setup a call and profile this through with you (aws-lambda-powertools-feedback@), and we'll send you a link with slots available. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Hey @barreeeiroo - that's unusual, at most, AWS SDK would incur ~200ms for creating a SDK Client + TLS Handshake (Session creation), though I've seen north of 300 lately if using a newer SDK version.
X-Ray SDK will add at worst 300-400ms (uses AWS SDK + some non-optimised path).
This should be amortised by a warm start. Higher memory functions have a lower cold start because of the CPU Slicing Lambda does, so you have more room for cryptography operations AWS SDK and TLS require -- Lambda PowerTuning can be a pragmatic way to find what optimum looks like.
Powertools being a thin wrapper, specially in Parameters, it'll only inherit what SDK and X-Ray does, and slow down on call stacks and …