aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

aws_lambda_nodejs: Unexisting `AWS_NODEJS_CONNECTION_REUSE_ENABLED` env variable set to `1` as default

Open garysassano opened this issue 11 months ago • 3 comments

Describe the bug

The AWS SDK for JavaScript v3 is included by default in AWS Lambda Node.js 18 and Node.js 20 runtimes.

NodejsFunction construct comes with an awsSdkConnectionReuse optional prop, which is set to true by default. This default automatically sets the AWS_NODEJS_CONNECTION_REUSE_ENABLED environment variable to 1 in the Lambda function's configuration.

However, it has been identified that the AWS_NODEJS_CONNECTION_REUSE_ENABLED environment variable does not exist in AWS SDK for JavaScript v3, rendering the variable obsolete for those utilizing the more recent Lambda runtimes. This situation not only leads to unnecessary configuration, but it also has a performance impact. The inclusion of this redundant environment variable is associated with a 20ms increase in cold start times, highlighting an opportunity for performance improvement by removing this default setting for those who do not require it.

Expected Behavior

see above

Current Behavior

see above

Reproduction Steps

see above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.132.1

Framework Version

No response

Node.js Version

20.11.1

OS

Ubuntu 22.04.3 LTS

Language

TypeScript

Language Version

No response

Other information

No response

garysassano avatar Mar 14 '24 23:03 garysassano

The new default for awsSdkConnectionReuse should either be always false, or:

  • false for nodejs20.x and nodejs18.x
  • true for nodejs16.x

garysassano avatar Mar 14 '24 23:03 garysassano

Yes I agree with your proposed solution. Making this a p1 but we welcome PRs as well.

pahud avatar Mar 18 '24 16:03 pahud

This will actually become a moot point in just a few weeks or so. We are removing use of v2 from the CDK.

TheRealAmazonKendra avatar Mar 27 '24 22:03 TheRealAmazonKendra

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar May 20 '24 17:05 github-actions[bot]