Skip to content

Commit

Permalink
feat: reuse connections in http client + increase max sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
Samika Kashyap committed May 29, 2024
1 parent 9820eb6 commit a424b9c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/services/queue/sqs-queue-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,6 +125,13 @@ export class SqsQueueService<TValue extends QueueMessageData>
region: config.queue.awsRegion,
endpoint: this.sqsQueueUrl,
logger: awsLogger,
requestHandler: new NodeHttpHandler({
httpAgent: new http.Agent({
keepAlive: true,
maxSockets: 50,
maxFreeSockets: 20,
}),
}),
})
this.maxTimeToHoldMessageSec =
config.queue.maxTimeToHoldMessageSec || DEFAULT_MAX_TIME_TO_HOLD_MESSAGES_S
Expand Down

0 comments on commit a424b9c

Please sign in to comment.