Skip to content

Commit

Permalink
To handle max socket warning while writing the item on DDb
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakhi Mundhada authored and Rakhi Mundhada committed Jul 25, 2024
1 parent 279bac0 commit c5a471b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alertlogic/paws-collector",
"version": "2.2.4",
"version": "2.2.5",
"license": "MIT",
"description": "Alert Logic AWS based API Poll Log Collector Library",
"repository": {
Expand Down
14 changes: 11 additions & 3 deletions paws_collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ const ERROR_CODE_COMPLETED_STATE = 'COMPLETED_STATE';
const SQS_VISIBILITY_TIMEOUT = 900;
const DDB_TTL_DAYS = 14;
const DEDUP_LOG_TTL_SECONDS = 86400;
let maxSocket = process.env.maxSocket ? process.env.maxSocket : 100;

// using short syntax from https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
const DDB_OPTIONS = {
maxRetries: 10,
ConsistentRead: true
};
ConsistentRead: true,
requestHandler: {
httpsAgent: {
maxSockets: maxSocket
}
}
}
const DDB_DELETE_BATCH_OPTIONS = {
maxBatchSize: 25,
maxBatchSizeBytes: 16 * 1024 * 1024
Expand Down Expand Up @@ -925,7 +933,7 @@ class PawsCollector extends AlAwsCollector {
*/
removeDuplicatedItem(logs, paramName, asyncCallback) {
let collector = this;
const ddb = new DynamoDB();
const ddb = new DynamoDB(DDB_OPTIONS);
let uniqueLogs = [];
var promises = [];
let duplicateCount = 0;
Expand Down

0 comments on commit c5a471b

Please sign in to comment.