From 406ebc67071486a680f38a6dd78b7cead2a377ec Mon Sep 17 00:00:00 2001 From: Mohsin Zaidi <2236875+smrz2001@users.noreply.github.com> Date: Tue, 11 Jun 2024 17:53:31 -0400 Subject: [PATCH] feat: reuse connections in dynamodb http client --- src/services/witness-service.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/services/witness-service.ts b/src/services/witness-service.ts index 5580abad..bb777fc3 100644 --- a/src/services/witness-service.ts +++ b/src/services/witness-service.ts @@ -8,6 +8,8 @@ import { Config } from 'node-config-ts' import { DynamoDB } from '@aws-sdk/client-dynamodb' import { logger } from '../logger/index.js' import { Utils } from '../utils.js' +import * as http from 'http' +import { NodeHttpHandler } from '@smithy/node-http-handler' const carFactory = new CARFactory() @@ -160,6 +162,11 @@ export class DynamoDbWitnessService extends WitnessService implements IWitnessSe this.dynamoDb = new DynamoDB({ region: config.witnessStorage.awsRegion, endpoint: config.witnessStorage.dynamoDbEndpoint, + requestHandler: new NodeHttpHandler({ + httpAgent: new http.Agent({ + keepAlive: true, + }), + }), }) this.tableName = config.witnessStorage.dynamoDbTableName || DEFAULT_WITNESS_TABLE_NAME this.ttl = config.witnessStorage.dynamoDbTtl || DEFAULT_WITNESS_TABLE_TTL