1
votes

I use DynamoDB DocumentClient to delete the item on multiple tables using Class: AWS.DynamoDB.DocumentClient

The issue is, when I tried to delete multiple tables use promised.all(), it run didn't delete the item but didn't return any exception from AWS. I'm thinking is because I didn't return the promise?

Other thing is, on the DynamoDB page, it mentioned write capacity as:

One write capacity unit represents one write per second for items up to 1 KB in size. If you need to write an item that is larger than 1 KB, DynamoDB will need to consume additional write capacity units. The total number of write capacity units required depends on the item size.

If each of my item is 0.4KB, I want to delete 1000 items, it will be 400 KB, then I should set the write capacity unit as 400 or 1000? (if I didn't delay the request at all).

return Promise.all([deleteItemOnTable(table1), deleteItemOnTable(table2)]);

var documentClient = new AWS.DynamoDB.DocumentClient();

function deleteItemOnTable(tablePramas, dataToBeDeleted){
var params = {
  TableName : 'TableName',
  Key: {
    HashKey: 'hashkey',
    NumberRangeKey: 1
  }
};
dataToBeDeleted.forEach(item=>
  var chain = Promise.resolve();
  chain = chain.
    then(()=>{
      documentClient.delete(params, function(err, data) {
        if (err) console.log(err);
        else console.log(data);
      });
    }).then(() => delay(10));
  }
);
1

1 Answers

1
votes

It sounds like your query parameters aren't getting any hits on your data. What does your data look like?

For the write capacity part of your question, it depends on how quickly you want the writes to happen. For 1000 in a second, the formula would be:

1KB (0.4KB rounded up) x 1000 writes per second = 1000 write capacity units

If you're going to spread the writes out over a longer period, say 100 per second, the formula would be:

1KB (0.4KB rounded up) x 100 writes per second = 100 write capacity units