Skip to content

Commit

Permalink
feat: reuse connections in http client + increase max sockets (#1220)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
samika98 and Samika Kashyap authored May 30, 2024
1 parent 9820eb6 commit c2121a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 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,11 @@ export class SqsQueueService<TValue extends QueueMessageData>
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
Expand Down

0 comments on commit c2121a0

Please sign in to comment.