Traceback(控制台的最后一个输出):
File "batchpy.py", line 61, in <module>
obj.batch_w1()
File "batchpy.py", line 49, in batch_w1
batch.put_item(data=item)
File "/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/table.py", line 1641, in __exit__
self.resend_unprocessed()
File "/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/table.py", line 1718, in resend_unprocessed
resp = self.table.connection.batch_write_item(batch_data)
File "/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/layer1.py", line 420, in batch_write_item
body=json.dumps(params))
File "/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/layer1.py", line 2842, in make_request
retry_handler=self._retry_handler)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 954, in _mexe
status = retry_handler(response, i, next_sleep)
File "/usr/local/lib/python2.7/dist-packages/boto/dynamodb2/layer1.py", line 2876, in _retry_handler
response.status, response.reason, data)
boto.dynamodb2.exceptions.ProvisionedThroughputExceededException: ProvisionedThroughputExceededException: 400 Bad Request
{u'message': u'The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API', u'__type': u'com.amazonaws.dynamodb.v20120810#ProvisionedThroughputExceededException'}
答案 0 :(得分:25)
DynamoDB使用预配置吞吐量模型进行读取和写入。这意味着如果您的应用程序尝试执行的读取或写入次数超过分配给表格的次数,则会收到错误。
AWS已经做了很多事情来帮助解决这个问题:
根据您正在创建的应用类型,您可以采取以下措施来处理这些错误:
答案 1 :(得分:15)
有两种方法可以解决这个问题:
提高吞吐量水平(对于此选项,您需要支付更多费用)。
通常我们在某些方面必须做的事情是我们需要在应用程序级别实现逻辑。例如,调用dynamoDB来检查异常。如果超过吞吐量,请休眠几秒钟并再次调用相同的查询(这是我们在应用程序中实现的)。