1

I need to know how many write units a certain object will consume before inserting it to DynamoDB.

There are some docs from AWS explaining how to estimate write units, however, I would like to check if there is some built in function in boto3 before writing my own.

import boto3

some_object = { ... }

dynamo = boto3.resource('dynamodb')

# get kb size my object will consume
size = dynamo.get_size_of(some_object)

# or even how many write units
writers = dynamo.get_writers(some_object)
Vikto
  • 512
  • 1
  • 7
  • 19
  • 2
    This might be helpful: https://zaccharles.github.io/dynamodb-calculator/ It has an implementation in JavaScript that could help you to translate to Python. Also be aware of the awscli's `--returned-consumed-capacity TOTAL` option with `aws dynamodb put-item`. – jarmod Jan 30 '20 at 17:53

1 Answers1

1

There is nothing inside boto3 for calculating the size of items you're going to write. We sometimes use the code from this blog post to check python data structures before writing them.

tankthinks
  • 973
  • 6
  • 9