AWS official supported auto-scaling on DynamoDB
See: https://aws.amazon.com/blogs/aws/new-auto-scaling-for-amazon-dynamodb
Use DynamoDB autoscaling with lambda!
It's Dynamic DynamoDB's simple lambda version
- autoscale DynamoDB's provisioned read/write capacity
- run by lambda functon with scheduled event
- index.js - main handler & flow source. using async
- tasks.js - Detail work sources. using AWS SDK
- config.js - capacity scaling rule configuration
$ git clone https://github.com/rockeee/dynamic-dynamodb-lambda.gitor download zip$ npm installto download npm modules- modify
config.jsfor your configuration.
- almost same with Dynamic DynamoDB's option
module.exports={region : 'us-west-2',// regiontimeframeMin : 5,// evaluation timeframe (minute)tables :
[{tableName : 'testTable',// table namereads_upper_threshold : 90,// read incrase threshold (%)reads_lower_threshold : 30,// read decrase threshold (%)increase_reads_with : 90,// read incrase amount (%)decrease_reads_with : 30,// read decrase amount (%)base_reads : 5,// minimum read Capacitywrites_upper_threshold : 90,// write incrase amount (%)writes_lower_threshold : 40,// write decrase amount (%)increase_writes_with : 90,// write incrase amount (%)decrease_writes_with : 30,// write incrase amount (%)base_writes : 5// minimum write Capacity},{tableName : 'testTable2',reads_upper_threshold : 90,reads_lower_threshold : 30,increase_reads_with : 0,// to don't scale up readsdecrease_reads_with : 0,// to don't scale down readsbase_reads : 3,writes_upper_threshold : 90,writes_lower_threshold : 40,increase_writes_with : 0,// to don't scale up writesdecrease_writes_with : 0,// to don't scale down writesbase_writes : 3}// additional table...]};- deploy to lamda function with your favorite method (just zip, or use tool like node-lambda)
- check lambda function's configuration
- memory - 128MB, timeout - 10sec
- set
Cloudwatch Event Ruleto run your lambda function. for detail, refer this - set & attach
roleto lambda function - example role policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Action": [
"dynamodb:DescribeTable",
"dynamodb:UpdateTable",
"CloudWatch:getMetricStatistics"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Sid": "",
"Resource": "*",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Effect": "Allow"
}
]
}- more stable
- add SNS noti when scaled/failed