Skip to content

kaievns/save-your-dosh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Save Your Dosh

This is a little gem for heroku that automatically scales dynos in your heroku/rails based app.

Prerequisites

You obviously have to be on heroku and rails. You also need the New Relic RPM add-on switched on. It doesn't matter whether you have a free or a pro account on new relic.

Installation

Hook it up as a rubygem in your Gemfile

gem 'save-your-dosh'

Make sure you have the following ENV vars in your heroku config

» heroku config
=== doshmosh Config Vars
.....
APP_NAME:                   your-heroku-app-name
HEROKU_API_KEY:             your-heroku-api-key
NEW_RELIC_API_KEY:          your-new-relic-api-key
NEW_RELIC_APP_NAME:         your-app-name-on-new-relic
NEW_RELIC_ID:               your-account-id-on-new-relic
......

It is very likely have you won't already have your APP_NAME and HEROKU_API_KEY in there, so add them with heroku config:add APP_NAME=foobar HEROKU_API_KEY=your_api_key.

You can get your Heroku API Key from https://dashboard.heroku.com/account but unfortunately, Heroku's API is currenly on a per-account basis, not a per-application basis.

Once you've done with those, add the rake save:your:dosh task in heroku's scheduler and set the minimal timeout of 10 mins. (don't make it less than 6 mins, otherwise new relic will kick your ass)

Configuration

You can mangle with the settings by creating a file like that in your rails app config/save-your-dosh.yml

dynos:
  min: 1
  max: 5
  threshold: 50 # % of system busyness when we kick in/out a dyno

How It Works

It's pretty simple, every time you kick the rake save:your:dosh task via cron or scheduler, it will make a request to the new relic servers for the data on your application busyness. If it goes over the threshold, it will increase the amount of dynos until reaches the max number from the config. Otherwise it will try to switch dynos off until reaches the minimal amount.

License

All the code in this package released under the terms of the MIT license Copyright (C) 2012 Nikolay Nemshilov

About

Heroku dynos auto-scaling thing

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages