npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dynamodb-cost-optimizer

v0.0.1

Published

Optimize AWS DynamoDB for cost

Downloads

1

Readme

DynamoDB Cost Optimizer

Optimize your DynamoDB tables based on past usage

Install

Install globally if you want to use the CLI.

yarn global add dynamodb-cost-optimizer
# or
npm i -g dynamodb-cost-optimizer

Install locally if you want to use it as a library.

yarn add dynamodb-cost-optimizer
# or
npm i --save dynamodb-cost-optimizer

Usage

The utility estimates how much the table would have cost using different setups. You still need to take into account if your usage is varied, if it's predictable, and if it's spiky. Also keep in mind that past usage patterns is no guarantee for future usage patterns. This utility is just a course guide. If you blindly configure your tables to use the cheapest option you're gonna have a bad time.

CLI

$ dynamodb-cost-optimizer --help
Options:
      --version    Show version number                                 [boolean]
  -t, --tableName  DynamoDB table to optimize                [string] [required]
  -s, --startTime  Consider metrics from this time           [string] [required]
  -e, --endTime    Consider metrics up to this time                     [string]
      --help       Show help                                           [boolean]
$ dynamodb-cost-optimizer -t MyTable -s 2021-04-07T00:00:00
{
  "tableName": "MyTable",
  "currentMode": "PAY_PER_REQUEST",
  "onDemandCost": {
    "millionReads": 1,
    "millionWrites": 1,
    "readCost": "$0.28",
    "writeCost": "$1.41",
    "sum": "$1.70"
  },
  "provisionedCost": {
    "RCU": 190,
    "WCU": 1,
    "readCost": "$4.62",
    "writeCost": "$0.12",
    "sum": "$4.74"
  },
  "autoscalingCost": {
    "RCU": 2,
    "WCU": 1,
    "spikyRead": false,
    "spikyWrite": true,
    "readCost": "$0.05",
    "writeCost": "$0.12",
    "sum": "$0.17"
  }
}

As a library

import { ddbCostOptimize } from 'dynamodb-cost-optimizer'

ddbCostOptimize({ TableName: 'MyTable', StartTime: new Date('2021-04-07T00:00:00') })
  .then(console.log)

Output

onDemandCost

millionReads: How many million reads were found during the period.

millionWrites: How many million writes were found during the period.

readCost: How much the above reads would cost.

writeCost: How much the above writes would cost.

sum: readCost + writeCost.

provisionedCost

RCU: The max consumed read units found during the period.

WCU: The max consumed write units found during the period.

readCost: How much the above read capacity would cost if provisioned.

writeCost: How much the above write capacity would cost if provisioned.

sum: readCost + writeCost.

autoscalingCost

RCU: The average RCU needed to keep the consumed read units found during the period at 70% utilization.

WCU: The average WCU needed to keep the consumed write units found during the period at 70% utilization.

spikyRead: true if consumed reads more than double over a 5 min period. This could indicate that the table is unsuitable to use autoscaling.

spikyWrite: true if consumed writes more than double over a 5 min period. This could indicate that the table is unsuitable to use autoscaling.

readCost: How much the above read capacity would cost if provisioned.

writeCost: How much the above write capacity would cost if provisioned.

sum: readCost + writeCost.

API

TableName

Type: string
Required: yes

The DynamoDB table to analyze.

StartTime

Type: Date
Required: yes

Consider metrics from this time.

EndTime

Type: Date
Default: new Date()

Consider metrics up to this time.

cw

Type: AWS.CloudWatch
Default: new CloudWatch()

The AWS CloudWatch client to use for CloudWatch API calls.

ddb

Type: AWS.DynamoDB
Default: new DynamoDB()

The AWS DynamoDB client to use for DynamoDB API calls.

Developing

  1. Clone the repo
  2. Run yarn install
  3. Run yarn test-watch to run the tests while deving
  4. Run git add . && yarn cm to commit changes using commitizen
  5. Run yarn release to create a new version using standard-version

Lint checks and tests are run automatically on commit and built by the pipeline on push.

License

dynamodb-cost-optimizer is licensed under the terms of the MIT license.