Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB Update/Put throttled despite high provisioned capacity

I am seeing some throttles on my updates on DynamoDB table. I know that throttle work on per second basis, that peaks above provisioned capacity can be sometimes absorbed, but not guaranteed. I know that one is supposed to evenly distribute the load, which I have not done.

BUT please look at the 1 minute average graphs from metrics; attached. The utilized capacity is way below the provisioned capacity. Where are these throttles coming from? Because all writes went to a particular shard?

There are no batch writes. The workload distribution is something that cannot, easily, control.

enter image description here enter image description here

like image 820
Amit Avatar asked Dec 19 '15 11:12

Amit


People also ask

Why is my DynamoDB table throttled?

Your DynamoDB on-demand table might be throttled due to one of the following common reasons: The traffic is more than double the previous peak. The traffic exceeds the per-partition maximum. The traffic exceeds the per-table account quota.

What happens if your application's read or write requests exceed the provisioned throughput for a table in DynamoDB?

If your application's read or write requests exceed the provisioned throughput for a table, DynamoDB might throttle that request. When this happens, the request fails with an HTTP 400 code (Bad Request), accompanied by a ProvisionedThroughputExceededException.

How do I stop DynamoDB throttling?

To avoid this poor performance, distribute the read and write operations as evenly as possible across your table. For more information, see Designing partition keys to distribute your workload evenly and Choosing the right DynamoDB partition key.

What happens when DynamoDB is throttled?

A throttled DynamoDB table can significantly impact the performance of your application and ultimately lead to loss of data. As developers, it is essential to have a good understanding of these limitations to prevent them.


1 Answers

DynamoDB is built on the assumption that to get the full potential out of your provisioned throughput your reads and writes must be uniformly distributed over space (hash/range keys) and time (not all coming in at the exact same second).

Based on the allocated throughput on your graphs you are still most likely at one shard, but it is possible that there are two or more shards if you have previously raised the throughput above the current level and lowered it down to what it is at now. While this is something to be mindful of, it likely is not what is causing this throttling behavior directly. If you have a lot of data in your table, over 10 GB then you definitely will have multiple shards. This would mean you likely have a lot of cold data in your table and that may be causing this issue, but that seems less likely.

The most likely issue is that you have some hot keys. Specifically, you have one or just a few records that are receiving a very high number of read or write requests and this is resulting in throttling. Essentially DynamoDB can support massive IOPS for both writes and reads, but you can't apply all of those IOPS to just a few records, they need to be distributed among all of the records uniformly in an ideal situation.

Since the number of throttles you were showing is in the order of magnitude of 10s to 100s it may not be something to worry about. As long as you are using the official AWS SDK it will automatically take care of retries with exponential backoff to retry requests several times before completely giving up.

While it is difficult in many circumstances to control the distribution of reads and writes to a table, it may be worth taking another look at your hash/range key design to make sure it is really optimal for your pattern of reads and writes to the table. Also, for reads you may employ caching through Memcached or Redis, even if the cache expired in just a few minutes or a few seconds to help reduce the impact of hot keys. For writes you would need to look at the logic in the application to make sure there are not any unnecessary writes being performed that could be causing this issue.

One last point related to batch writes: A batch operation in DynamoDB does not reduce the consumed amount of read or writes the different child requests consume, it simply reduces the overhead of making multiple HTTP requests. While batch requests generally help with throughput, they are not useful at reducing the likelihood of throttling in DynamoDB.

like image 152
JaredHatfield Avatar answered Oct 12 '22 23:10

JaredHatfield