-
Notifications
You must be signed in to change notification settings - Fork 634
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
When I updated to Node 22 on Lambda using the AWS Javascript SDK V3 last year, it added at least 50 ms to my coldstart times. For awhile I assumed it was due to the edge caches not being warm, but recently the lambda perf benchmark was updated with Node 22 and showed no appreciable difference in coldstart times between Node 20 and Node 22. I investigated further and it appears it is only when using the AWS Javascript SDK V3. In Node 22, it loads the http request bits that add 50 ms to the coldstart even if they aren't used. Similar to #6144, adding some lazy loading logic on the http request and agent should keep the coldstart performance inline with Node 20.
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/client-sts 3.750
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
Node 22.11
Reproduction Steps
I've created a repro with instructions here.
Observed Behavior
Node 22 exhibits 50 additional ms of coldstart time over Node 20 in the Lambda environment.
Here is a snippet from the README in the repro:
- Runs 1 and 2 show the baseline without the AWS SDK.
- Runs 3 and 4 show the difference between Node 20 and Node 22 with the AWS SDK.
- Runs 5 and 6 show the difference between Node 20 and Node 22 with a patch that removes http from the AWS SDK.
These are samples from my runs, but the results were repeatable.
run | node version | @initDuration | notes |
---|---|---|---|
1 | 20.18 | 142.79 | No AWS V3 SDK |
2 | 22.11 | 142.26 | No AWS V3 SDK |
3 | 20.18 | 204.23 | With AWS V3 SDK |
4 | 22.11 | 255.26 | With AWS V3 SDK |
5 | 20.18 | 200.42 | With patched AWS V3 SDK |
6 | 22.11 | 203.62 | With patched AWS V3 SDK |
Expected Behavior
Similar coldstart performance between Node 20 and Node 22.
Possible Solution
Lazy load the http request and agent bits.
Additional Information/Context
No response