Ex:Try out capacity modes
Hands-on Exercise
This exercise is carried out in AWS cloud as a result it may cost you money. To minimize the cost make sure to delete the table at the end of this exercise.
Pre-requisites
- AWS Account
- AWS CLI setup for connecting AWS cloud
- Permissions to run DynamoDB operations
- Permissions to access the console
1. Run python code to create a table
- Python is code available in the subfolder Python
- python/create-table-provisioned.py
- Review the code
- Code takes 3 arguments TABLE-Name, RCU, WCU
- Command below will create a table with provisioned capacity of RCU=1, WCU=1
python python/create-table-provisioned.py my-table 1 1
- Wait for table to get created. It may take a minute or so.
aws dynamodb list-tables
2. Populate table with random item data
- Use the Python code
- python/generate-random-items.py
- Review the code
- Run the code to generate 10K items
This will result in error !! Can you guess why?
python python/generate-random-items.py my-table
3. Change the capacity mode for the table & try again
- You may change it in AWS Management Console
- OR you may use the command below to change the mode
aws dynamodb update-table --table-name my-table \
--billing-mode PAY_PER_REQUEST
- Confirm billing mode is changed
aws dynamodb describe-table --table-name my-table
4. Populate table with random item data
- Use the Python code
- python/generate-random-items.py
- Review the code
- Run the code to generate 10K items
This time there will be NO error !! Can you guess why?
python python/generate-random-items.py my-table
5. Delete the table
aws dynamodb delete-table --table-name my-table
6. (Optional) Checkout the metrics in Cloudwatch
- CloudWatch captures DynamoDB table metrics
- In this graph you see the metrics WriteThrottleEvents that occured due to the low provisioned capacity
- The other metrics is the ConsumedWriteCapacity