scalemate

1.0.2 • Public • Published

scalemate

npm version

A Node.js package that scales your application servers by publishing custom CloudWatch metrics which are not available by default, such as:

  • Memory Available - amount of system memory available
  • Sockets Used - number of open client/server connections

Scalemate supports per-second metric resolution and defaults to per-minute.

Usage

First, install the package using npm:

npm install -g scalemate

Then, create a file called config.js and paste the following inside it:

module.exports = {
    // Metrics to publish
    metrics: {
        // Number of open socket connections
        socketsUsed: {
            // Whether to publish this metric
            enabled: true,
            // CloudWatch unit type
            unit: 'Count',
            // CloudWatch metric title
            name: 'Sockets Used'
        },
        // Number of megabytes of system memory currently available
        memoryAvailable: {
            // Whether to publish this metric
            enabled: true,
            // CloudWatch unit type
            unit: 'Count',
            // CloudWatch metric title
            name: 'Memory Available'
        }
    },
    // Metric interval (in seconds)
    interval: 60,
    // CloudWatch namespace to associate metrics with
    namespace: 'MyApp',
    // AWS IAM user with CloudWatch read/write access
    credentials: {
        region: 'us-east-1',
        accessKeyId: 'ABCDEFG',
        secretAccessKey: 'ABCDEFGHIJK/HIJKLMNOPQRS'
    }
};

Modify the configuration file according to your own needs, enabling or disabling metrics and configuring the following parameters:

  • namespace - the name of your app or server cluster
  • credentials - an AWS IAM user with read/write access to CloudWatch

Test the configuration by running:

scalemate

Observe the terminal output for any initial errors and for successfully-published metrics. If no errors are emitted, you have successfully configured Scalemate.

Visit the CloudWatch console and find the published metrics under the Scalemate namespace: https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#

You can now configure CloudWatch alarms to scale your EC2 instances up or down based on these metrics.


Leave the tool running on a remote server by executing the following command:

scalemate > /tmp/scalemate.log &

To start Scalemate automatically after system reboots, add the following to your user's crontab:

@reboot scalemate -c /path/to/config.js > /tmp/scalemate.log &

License

Apache 2.0

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    1
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i scalemate

Weekly Downloads

1

Version

1.0.2

License

Apache-2.0

Unpacked Size

20.4 kB

Total Files

9

Last publish

Collaborators

  • eladnava