New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lambda-nodejs): connection reuse with aws-sdk #9083
Conversation
The default Node.js HTTP/HTTPS agent creates a new TCP connection for every new request. To avoid the cost of establishing a new connection, configure the SDK for JavaScript to reuse TCP connections. For short-lived operations, such as DynamoDB queries, the latency overhead of setting up a TCP connection might be greater than the operation itself. See https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
2b24825
to
8de5106
Compare
229eff7
to
2b24825
Compare
@@ -69,6 +69,9 @@ export class NodejsFunction extends lambda.Function { | |||
}), | |||
handler: `index.${handler}`, | |||
}); | |||
|
|||
// Enable connection reuse for aws-sdk | |||
this.addEnvironment('AWS_NODEJS_CONNECTION_REUSE_ENABLED', '1'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like we need an opt-out option for this.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
The default Node.js HTTP/HTTPS agent creates a new TCP connection for every new request. To avoid the cost of establishing a new connection, configure the SDK for JavaScript to reuse TCP connections. For short-lived operations, such as DynamoDB queries, the latency overhead of setting up a TCP connection might be greater than the operation itself. See https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The default Node.js HTTP/HTTPS agent creates a new TCP connection for every new request. To avoid the cost of establishing a new connection, configure the SDK for JavaScript to reuse TCP connections. For short-lived operations, such as DynamoDB queries, the latency overhead of setting up a TCP connection might be greater than the operation itself. See https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The default Node.js HTTP/HTTPS agent creates a new TCP connection for
every new request. To avoid the cost of establishing a new connection,
configure the SDK for JavaScript to reuse TCP connections.
For short-lived operations, such as DynamoDB queries, the latency overhead of
setting up a TCP connection might be greater than the operation itself.
See https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license