Search code examples
amazon-dynamodb

How to solve throughput error for dynamodb?


Traceback (the last output from console):

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'}

Solution

  • There are few ways you can handle this problem:

    1. Increase the level of throughput (for this option you have to pay more).

    2. Implement at an application level. For instance, call DynamoDB to check for an exception. If throughput is exceeded, sleep for some seconds and call the same query again (this is what we have implemented in our app).

    Edit:

    1. DynamoDB has added one more feature for On-Demand capacity. In this, we don't have to define any specific capacity for our table as DynamodB itself will perform auto-scaling for us.