GithubHelp home page GithubHelp logo

dynamic-dynamodb-lambda's Introduction

Dynamic DynamoDB - lambda

Use DynamoDB autoscaling with lambda!
It's Dynamic DynamoDB's simple lambda version

functional/running test passed. but before use, Test it please
please give me any report/suggestion, Welcome

Feature

  • autoscale DynamoDB's provisioned read/write capacity
  • run by lambda functon with scheduled event

File Structure

  • index.js - main handler & flow source. using async
  • tasks.js - Detail work sources. using AWS SDK
  • config.js - capacity scaling rule configuration

How to use

  1. $ git clone https://github.com/rockeee/dynamic-dynamodb-lambda.git or download zip
  2. $ npm install to download npm modules
  3. modify config.js for your configuration.
module.exports = {
 region : 'us-west-2', // region
 timeframeMin : 5, // evaluation timeframe (minute)
 tables :
     [
         {
         tableName : 'testTable',     // table name
         reads_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 Capacity
         writes_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 reads
         decrease_reads_with : 0,     // to don't scale down reads
         base_reads : 3,
         writes_upper_threshold : 90,
         writes_lower_threshold : 40,
         increase_writes_with : 0,    // to don't scale up writes
         decrease_writes_with : 0,    // to don't scale down writes
         base_writes : 3
         }
         // additional table...
     ]
};
  1. deploy to lamda function with your favorite method (just zip, or use tool like node-lambda)
  2. check lambda function's configuration
  • memory - 128MB, timeout - 10sec
  • set Cloudwatch Event Rule to run your lambda function. for detail, refer this
  • set & attach role to 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"
     }
 ]
}

Roadmap

  • more stable
  • add SNS noti when scaled/failed

dynamic-dynamodb-lambda's People

Contributors

dhoeric avatar log-just avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dynamic-dynamodb-lambda's Issues

Need to Throttle Decreases

You should try to implement something like I have done at https://github.com/bradmurray/DynamoDBLambdaMonitor when it comes to decreases. The problem I ran into in using mine was that all four decreases would usually get used up in the first hour of the day and my savings on provisioning would be minimal. My basic logic is such that you can only use up to 1 decrease in the first 6 hours, 2 in the first 12 and so on. My implementation does not have multi-table as yours does.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.