sorenandersen.com

Optimze DynamoDB operations by enabling HTTP keep-alive

August 25, 2020

Instruct the Node.js AWS SDK to reuse client connections to avoid the overhead of creating new TCP connections:

provider:
  name: aws
  runtime: nodejs12.x
  environment:
    AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1

Now, with above environment variable set - and while the Lambda function remains “warm” - outgoing HTTP connections can be reused and that will speed up e.g. DynamoDB DocumentClient operations.

I’ve set up a quick test myself doing both put and get operations and I can confirm the performance gains that Yan writes about in more detail. The time spent executing those database operations is down to approximately 1/3.

References


Søren Andersen

Digital garden of Søren Andersen.
Posts on tech that I use and learn.