DynamoDB throttling


I am wondering if I set write capacity to dynamodb and some of the requests got "throttled" , are they eventually entering the database later?

asked a year ago1352 views
5 Answers

For your application to run smoothly, you need to add logic to catch and respond to errors. Typical approaches include using try-catch blocks or if-then statements.

The AWS SDKs perform their own retries and error checking. If you encounter an error while using one of the AWS SDKs, the error code and description can help you troubleshoot it.

Each AWS SDK implements retry logic automatically. You can modify the retry parameters to your needs. For example, consider a Java application that requires can only tolerate 3 retries. With the AWS SDK for Java, you could use the ClientConfiguration class and provide a maxRetries value of 3 to allow only 3 retries. For more information, see the AWS SDK documentation for your programming language.

In addition to simple retries, each AWS SDK implements an exponential backoff algorithm for better flow control. The concept behind exponential backoff is to use progressively longer waits between retries for consecutive error responses. For example, up to 50 milliseconds before the first retry, up to 100 milliseconds before the second, up to 200 milliseconds before third, and so on. However, after a minute, if the request has not succeeded, the problem might be the request size exceeding your provisioned throughput, and not the request rate. Set the maximum number of retries to stop around one minute. If the request is not successful, investigate your provisioned throughput options.

In summary, your SDK will automatically retry to a fixed number of times before throwing an exception which you can catch in a try/catch block. If no exceptions were thrown it means that your items were successfully persisted with one of the retries. Retries are configurable, each of the SDK's have a different default value, e.g Java SDK V1 uses 10 as default, and Java SDK V2 uses 8.

profile pictureAWS
answered a year ago

, are they eventually entering the database later?

No, the application must retry.

Managing settings on DynamoDB provisioned capacity tables - Amazon DynamoDB

If your application performs reads or writes at a higher rate than your table can support, DynamoDB begins to throttle those requests. When DynamoDB throttles a read or write, it returns a ProvisionedThroughputExceededException to the caller. The application can then take appropriate action, such as waiting for a short interval before retrying the request.

profile picture
answered a year ago

Hi, The short answer is no. If you exceed your Provisioned Write Capacity, you will start to get theProvisionedThroughputExceededException error.

Here is some more info on how to deal with throttling and how to deal with it.

From the docs ... https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.ProvisionedThroughput.Manual

Provisioned throughput is the maximum amount of capacity that an application can consume from a table or index. If your application exceeds your provisioned throughput capacity on a table or index, it is subject to request throttling.

Throttling prevents your application from consuming too many capacity units. When a request is throttled, it fails with an HTTP 400 code (Bad Request) and a ProvisionedThroughputExceededException. The AWS SDKs have built-in support for retrying throttled requests (see Error retries and exponential backoff), so you do not need to write this logic yourself.

profile pictureAWS
answered a year ago

Something to remember is that SDKs will retry internally some number of times if they see a throttle exception, so it's entirely possible that in CloudWatch you'll see throttling happening while at the same time everything seems to have been written and your application won't seem to notice any issues.

If the throttling is sustained long enough then the application will see the exception from the SDK call and at that point it needs to either do an explicit retry or else the write will not happen.

answered a year ago

No, you will have to increase the WCU or set your capacity mode to provisioned auto-scaling if you are unsure of the WCU to set.

profile picture
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions