- Le plus récent
- Le plus de votes
- La plupart des commentaires
There is no difference in capacity consumption between clients. Ensure that you set you are not setting your reads to be strongly consistent, as this would consume double the capacity and is aligned with your issue.
Read consistency is eventual consistent by default.
SDK V2
npm list
Nodetest@ /Users/lhnng/Documents/Nodetest
├── aws-sdk@2.1380.0
└── dynamodb-doc@1.0.0
{ TableName: 'test', CapacityUnits: 150.5 }
SDK V3
npm list
NodetestV3@ /Users/lhnng/Documents/NodetestV3
├── @aws-sdk/client-dynamodb@3.284.0
└── @aws-sdk/lib-dynamodb@3.272.0
{
CapacityUnits: 150.5,
GlobalSecondaryIndexes: undefined,
LocalSecondaryIndexes: undefined,
ReadCapacityUnits: undefined,
Table: undefined,
TableName: 'test',
WriteCapacityUnits: undefined
}
Request:
client.query({
"TableName": 'test',
"KeyConditionExpression": `#pk = :val`,
"ExpressionAttributeNames": {
"#pk": "pk"
},
"ExpressionAttributeValues": {
":val": "sample_pk"
},
"ReturnConsumedCapacity": "TOTAL"
})
.promise() // V2 has promise, V3 returns a promise by default
.then(res => console.log(res['ConsumedCapacity']))
.catch(err => console.log(err))
Conclusion
As I mentioned previously, there are no differences in consumed capacity depending on the client. I also ran using the CLI to assure you that there are no differences:
aws dynamodb query \
--table-name test \
--key-condition-expression "#pk = :pk" \
--expression-attribute-values '{":pk":{"S":"sample_pk"}}' \
--expression-attribute-names '{"#pk":"pk"}' \
--select COUNT \
--return-consumed-capacity TOTAL
{
"Count": 26,
"ScannedCount": 26,
"ConsumedCapacity": {
"TableName": "test",
"CapacityUnits": 150.5
}
}
I have the exact same issue, I am using aws-sdk
v2 and scan all data from dynamodb by while loop with LastEvaluatedKey, and everything works fine, after I upgrade to @aws-sdk/client-dynamodb
, the ProvisionedThroughputExceededException is thrown, all configuration are exactly same, I am not setting ConsistentRead to true, I also tried paginateScan, the same error occurs.
Contenus pertinents
- demandé il y a un an
- demandé il y a un an
- demandé il y a 2 mois
Thank you very much for your reply, however as you can see from the configuration I have brought, I have not entered any changes. If there is a way to set the parameter to the default value, I would thank you if you could explain how. Or is there some reason why @aws-sdk keeps saying that I have reached ProvisionedThroughputExceededException preventing me from continuing whereas with aws-sdk it doesn't?
Can you provide me the version which you used in V2 and the version you now use in your upgraded V3. I will run some tests to ensure the SDK has not regressed.
Of course: aws-sdk: "2.1380.0" dynamodb-doc: "1.0.0" @aws-sdk/client-dynamodb: "3.284.0" @aws-sdk/lib-dynamodb: "3.272.0"
Thanks for that, updated my answer with my tests
I also tested for pagination scan, and the results are
And everything works fine, all results are scanned without error.
So the scanned count and Consumed CapacityUnits are no difference, but aws-sdk v3 throws error.