Aws-sdk-java: [DynamoDB] ProvisionedThroughputExceededException

Created on 5 Feb 2015  路  2Comments  路  Source: aws/aws-sdk-java

Hi!

I'm getting ProvisionedThroughputExceededException when I call batchWriteItemUnprocessed.

Is it normal behavior to force user handle such things? And how should we handle it?

Thanks!

Most helpful comment

The SDK automatically retries several times (with built-in exponential backoff) when it gets a ProvisionedThroughputExceeded response from DynamoDB. You'll only get the ProvisionedThroughputExceededException if you're still getting throttled after all of these retries.

You can configure the number and frequency of these retries by specifying a custom RetryPolicy when creating your client, but if this is happening enough that the default retries aren't enough to smooth it over, chances are your table is underprovisioned. To fix this, you should either increase the provisioned write throughput for the table and/or limit the rate at which you're sending writes to less than your provisioned capacity.

Hope that helps!

All 2 comments

The SDK automatically retries several times (with built-in exponential backoff) when it gets a ProvisionedThroughputExceeded response from DynamoDB. You'll only get the ProvisionedThroughputExceededException if you're still getting throttled after all of these retries.

You can configure the number and frequency of these retries by specifying a custom RetryPolicy when creating your client, but if this is happening enough that the default retries aren't enough to smooth it over, chances are your table is underprovisioned. To fix this, you should either increase the provisioned write throughput for the table and/or limit the rate at which you're sending writes to less than your provisioned capacity.

Hope that helps!

Looking at the code, I don't think david-at-aws's answer is correct. The DefaultBatchWriteRetryStrategy has DEFAULT_MAX_RETRY = -1;, i.e. keep retrying forever: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBMapperConfig.java#L852

However it also looks like the retry logic would never get executed anyway in this case. In doBatchWriteItemWithRetry() at https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBMapper.java#L1223-L1231, a ProvisionedThroughputExceeded exception would result in a FailedBatch being returned immediately, so you'd never get to the actual retry logic further down in the while loop.

Can you please re-open this ticket and take a look?

Was this page helpful?
0 / 5 - 0 ratings