当我创建大量数据时,dynamodb
引发ProvisionedThroughputExceededException
错误。我不想改变容量。我如何在node.js中处理这个
2021-09-30T07:01:05.608Z 9ec62d61-f9c5-4bd1-8853-fb6466f269cd INFO ProvisionedThroughputExceededException: The level of configured provisioned throughput for one or more global secondary indexes of the table was exceeded. Consider increasing your provisioning level for the under-provisioned global secondary indexes with the UpdateTable API
at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/json.js:52:27)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:690:12)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
code: 'ProvisionedThroughputExceededException',
time: 2021-09-30T07:01:05.605Z,
requestId: '9KVC4C9JUSB400051MGBMIF6URVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: true
}
这样做的最佳方法是根本不定义已分配的容量。相反,你可以使用:
BillingMode: PAY_PER_REQUEST
使用PAY_PER_REQUEST计费模式意味着您是按需付费的定价计划。这里有一些有用的链接[1][2],可以给你更多的了解。
您看到的错误消息特别指出,这是一个或多个二级索引没有提供足够的吞吐量。可以从文档中读取以下内容:
为了避免潜在的节流,为全局二级索引提供的写容量应该等于或大于基表的写容量,因为新的更新同时写入基表和全局二级索引。
基本上,如果您不想增加GSI上的写容量单元,您应该只将最低配置的GSI可以处理的数据写入表。