Skip to content
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

Merged
merged 6 commits into from Jul 19, 2020

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Jul 15, 2020

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
@jogold jogold force-pushed the lambda-nodejs-connection-reuse branch from 2b24825 to 8de5106 Compare July 15, 2020 16:07
@jogold jogold force-pushed the lambda-nodejs-connection-reuse branch from 229eff7 to 2b24825 Compare July 15, 2020 16:16
eladb
eladb previously requested changes Jul 16, 2020
@@ -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');
Copy link
Contributor

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.

@mergify mergify bot dismissed eladb’s stale review July 16, 2020 10:20

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jul 19, 2020

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 703f00f
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Jul 19, 2020

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).

@mergify mergify bot merged commit 44c0400 into aws:master Jul 19, 2020
Chriscbr pushed a commit to Chriscbr/aws-cdk that referenced this pull request Jul 23, 2020
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*
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this pull request Aug 11, 2020
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*
@jogold jogold deleted the lambda-nodejs-connection-reuse branch August 17, 2020 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants