From c2121a04e01c800bbcc81a5f8edd466a2ff723de Mon Sep 17 00:00:00 2001 From: Samika Kashyap Date: Thu, 30 May 2024 12:41:41 -0700 Subject: [PATCH] feat: reuse connections in http client + increase max sockets (#1220) * feat: reuse connections in http client + increase max sockets * fix: bump up max free sockets * fix: only keep keep alive to true, rest use dafaults --------- Co-authored-by: Samika Kashyap --- src/services/queue/sqs-queue-service.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/services/queue/sqs-queue-service.ts b/src/services/queue/sqs-queue-service.ts index 91f56cc6..4887fc6d 100644 --- a/src/services/queue/sqs-queue-service.ts +++ b/src/services/queue/sqs-queue-service.ts @@ -21,6 +21,8 @@ import { AnchorBatchQMessage, RequestQMessage } from '../../models/queue-message import { Codec, decode } from 'codeco' import { AbortOptions } from '@ceramicnetwork/common' import { logger } from '../../logger/index.js' +import * as http from 'http' +import { NodeHttpHandler } from '@smithy/node-http-handler' const DEFAULT_MAX_TIME_TO_HOLD_MESSAGES_S = 21600 const DEFAULT_WAIT_TIME_FOR_MESSAGE_S = 10 @@ -123,6 +125,11 @@ export class SqsQueueService region: config.queue.awsRegion, endpoint: this.sqsQueueUrl, logger: awsLogger, + requestHandler: new NodeHttpHandler({ + httpAgent: new http.Agent({ + keepAlive: true, + }), + }), }) this.maxTimeToHoldMessageSec = config.queue.maxTimeToHoldMessageSec || DEFAULT_MAX_TIME_TO_HOLD_MESSAGES_S