-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DYNAMO_BATCH_WRITE_COMMAND_CONCURRENCY now can be set by env
- Loading branch information
1 parent
4764fc1
commit 6cbbca3
Showing
3 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
export const MAX_DYNAMO_BATCH_WRITE_ITEM_COUNT = 25; | ||
|
||
/** | ||
* Sending to dynamo X commands at a time, using about X * 25 write units per batch to not overwhelm DDB | ||
* and give production plenty of room to work with. With DDB Response times, you can expect about 10 batches per second. | ||
*/ | ||
const DEFAULT_DYNAMO_BATCH_WRITE_COMMAND_CONCURRENCY = 4; | ||
|
||
export const getDynamoBatchWriteCommandConcurrency = (): number => { | ||
const dynamoBatchWriteCommandConcurrencyFromEnv = | ||
process.env.DYNAMO_BATCH_WRITE_COMMAND_CONCURRENCY; | ||
const parsedDynamoBatchWriteCommandConcurrencyFromEnv = | ||
dynamoBatchWriteCommandConcurrencyFromEnv | ||
? parseInt(dynamoBatchWriteCommandConcurrencyFromEnv) | ||
: undefined; | ||
|
||
if ( | ||
parsedDynamoBatchWriteCommandConcurrencyFromEnv && | ||
!isNaN(parsedDynamoBatchWriteCommandConcurrencyFromEnv) | ||
) { | ||
return parsedDynamoBatchWriteCommandConcurrencyFromEnv; | ||
} | ||
|
||
return DEFAULT_DYNAMO_BATCH_WRITE_COMMAND_CONCURRENCY; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters