amazon-web-servicesamazon-dynamodbamazon-dynamodb-index

DynamoDB throughput doubled for GSI


I have an application running in AWS and using DynamoDB (among other things). I have a table that is fairly highly used that I'm looking at optimizing and I noticed something I don't understand. The table has 4 GSI's as well as the main table. The main table and one of the indexes have a write throughput generally around 40 (it has auto-scaling so it goes up and down but that's the general average during normal use hours). The other 3 indexes have a write throughput of 80, exactly double. Shouldn't it be the same as they are just writing the same things to either the table or the GSI?

The only thing I could think of was that I know that strongly consistent reads take double the throughput. However, these should be eventually consistent and that is talking about reads not writes anyway. I also couldn't find a place to change or even verify the consistency setting of the table. Lastly, though, if I read correctly the setting would be the same for the main table and the indexes so it doesn't make sense that it would be more for one than the other so I don't think this is it.

The only other difference I see is that the 3 indexes with higher throughput had a sort key and the one with lower throughput does not. However, the main table also has a sort key. I'm not sure why that would cause it but it's a difference I saw.

If anyone has any explanation of the doubling I would love to hear. I'm at a loss...

EDIT

Just to add some more information, here is the usage graph for the last 12 hours for the main table:

Main Table Usage

And here is for the index:

Index Usage

As you can see, they are basically identical except that the numbers on the index are doubled. It's like it's writing to the index twice for every time it writes to the main table.


Solution

  • What is happening here is throughput amplification due to updating values which are used as keys in your index.

    In DynamoDB you cannot update the value of a key, because doing so is essentially creating a new item.

    However, we must handle this situation when it comes to the keys of an index. This means that for every UpdateItem which updates the value of a GSI partition or sort key, DynamoDB does a DeleteItem and a PutItem on your index. This is why you see double the write throughput compared to your base table.