简体   繁体   中英

How to rate limit scan to AWS DynamoDB for AWS CLI?

I have created the following query to query my table :

aws dynamodb scan --table-name TableName --scan-filter '{
"attributeName" : {
    "AttributeValueList" : [ {"S" : "StringToQuery"}],
    "ComparisonOperator" : "CONTAINS"
}
}'

This is causing a spike in read capacity for that table, which will probably lead to throttling of customer requests. I couldn't find any command line option to limit the rate in https://docs.aws.amazon.com/cli/latest/reference/dynamodb/scan.html , but I did find a java script with rate limit : https://aws.amazon.com/blogs/developer/rate-limited-scans-in-amazon-dynamodb/

Is there any way to do it from AWS CLI?

You can disable pagination and manually make the paginated calls with a bash loop. This way you can delay a certain amount based on the time the previous call took and the consumed read capacity.

Went ahead with creating a new index over a value which i knew was almost always "Y", like isActive, and added a filter on top of the query. Since it was a new index, it didn't affect existing index capacity.

Answer by cementblocks would reduce the RCU consumed too, but I needed a guarantee that customers would not be impacted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM