Skip to content

Commit

Permalink
feat: set number of SQS consumers dynamically (#3472)
Browse files Browse the repository at this point in the history
  • Loading branch information
hassy authored Feb 10, 2025
1 parent b9f8a44 commit 4d5b174
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class SqsReporter extends EventEmitter {
// Debug info:
this.messagesProcessed = {};
this.metricsMessagesFromWorkers = {};

this.poolSize = typeof process.env.SQS_CONSUMER_POOL_SIZE !== 'undefined'
? parseInt(process.env.SQS_CONSUMER_POOL_SIZE, 10)
: Math.max(Math.ceil(this.count / 10), 75);
}

_allWorkersDone() {
Expand Down Expand Up @@ -326,7 +330,7 @@ class SqsReporter extends EventEmitter {
};

this.sqsConsumers = [];
for (let i = 0; i < 30; i++) {
for (let i = 0; i < this.poolSize; i++) {
const sqsConsumer = createConsumer(i);

sqsConsumer.on('error', (err) => {
Expand Down

0 comments on commit 4d5b174

Please sign in to comment.