Thursday, February 9, 2017

How to change read/write capacity in AWS DynamoDB?

Hi,

Yes, it is very easy to automate changes to DynamoDB capacity. This can be done via the CLI or any of the SDKs.

A few caveats:
1: You can increase capacity on a table an unlimited number of times per day, but you can only reduce capacity on that table 4x a day
2: Once you increase capacity, you're paying for that capacity for an hour. There's no saving to be had by trying to ramp capacity up and down in real time.

One way to automate scaling is with the Dynamic DynamoDB script, a third party tool that will ramp your capacity up and down based upon actual load. We have a blog article posted describing it's use.

That may be overkill for your situation. If you just want to turn capacity up during business hours to a fixed level, and then turn it down to lower level after hours, you can do that with a simple shell script. If you have a persistent EC2 instance running you can simply add these scripts to the crontab on that box, or run the AWC CLI command from Data Pipeline with a ShellCommandActivity (we provide a template for doing this).

If you're doing it in a shell script, it might look something like:

#!/bin/bash
TABLE="my_ddb_table"
WCU=50
RCU=50
aws dynamodb update-table --table-name $TABLE \
  --provisioned-throughput {"ReadCapacityUnits":$RCU ,"WriteCapacityUnits":$WCU }

The simplest solution would be to have one version to run in the morning and another for the evening.

Resource Link:

  1. https://forums.aws.amazon.com/thread.jspa?messageID=725985                 

No comments:

Post a Comment