如何处理配置的吞吐量异常dynamodb query_2

时间:2014-10-03 23:52:47

标签: python amazon-web-services boto

使用文档中的示例:

>>> rev_with_d = users.query_2(
...     account_type__eq='standard_user',
...     last_name__beginswith='D',
...     reverse=True,
...     limit=2
... )

>>> for user in rev_with_d:
...     print user['first_name']
'John'
'Jane'

在这种情况下如何处理吞吐量异常?

我已尝试在每个循环中使用指数退避,但异常不会被捕获。

编辑:

按要求追溯:

Traceback (most recent call last):
  File "kgraph.py", line 51, in <module>
    for user in rev_with_d:
  File "/Library/Python/2.7/site-packages/boto/dynamodb2/results.py", line 62, in __next__
    self.fetch_more()
  File "/Library/Python/2.7/site-packages/boto/dynamodb2/results.py", line 146, in fetch_more
    results = self.the_callable(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/boto/dynamodb2/table.py", line 1132, in _query
    **kwargs
  File "/Library/Python/2.7/site-packages/boto/dynamodb2/layer1.py", line 1522, in query
    body=json.dumps(params))
  File "/Library/Python/2.7/site-packages/boto/dynamodb2/layer1.py", line 2100, in make_request
    retry_handler=self._retry_handler)
  File "/Library/Python/2.7/site-packages/boto/connection.py", line 937, in _mexe
    status = retry_handler(response, i, next_sleep)
  File "/Library/Python/2.7/site-packages/boto/dynamodb2/layer1.py", line 2134, 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'}

1 个答案:

答案 0 :(得分:2)

我认为您最好设置max_page_size的{​​{1}}参数。
您应该设置一个基于表的读取吞吐量和项目大小的值。