Scale your Heroku apps on a time slot base.
$ heroku apps:create <APPLICATION-NAME>
$ heroku addons:create heroku-postgresql:hobby-dev
$ heroku addons:create heroku-redis:hobby-dev
$ heroku config:set REDIS_PROVIDER=REDIS_URL
$ git push heroku master
$ heroku run bundle exec rake db:migrate
$ heroku plugins:install git@github.com:heroku/heroku-oauth.git
$ heroku authorizations:create -d "Heroku Timed Scaler"
Created OAuth authorization.
ID: <ID>
Description: Heroku Timed Scaler
Scope: global
Token: <TOKEN>
From the authorization above, use TOKEN
. The APP_NAME
is the application you
wish to scale up.
$ heroku config:set HEROKU_OAUTH=<TOKEN> HEROKU_APP_NAME=<APP_NAME>
You might want to make sure your application has scaled before the given time
slot. To do this, you can set a SCALING_TIME
ENV variable. This will add the
given amount of time (in minutes) to your time slot.
Example, you set SCALING_TIME to 15 (minutes). Your time slot is at 15:30 until 16:30.
To start the scaling, this would mean it would scale up your application at 15:15. At 16:45, it will scale down your application again to the initial settings.
$ heroku config:set SCALING_TIME=15
If you want to protect your application, there's a simple way to put HTTP Basic Auth in front.
$ heroku config:set HTTP_AUTH_USER=<USERNAME> HTTP_AUTH_PASS=<PASSWORD>
You can import CSV files as a way to upload multiple time slots in one go.
from, to, formation_type, formation_size, formation_quantity
"2015-10-24 15:30", "2015-10-24 16:30", "web", "standard-2x", 4
"2015-11-24 15:30", "2015-10-24 16:30", "web", "standard-2x", 4
"2015-12-24 15:30", "2015-10-24 16:30", "web", "standard-2x", 4
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Run the tests (and make sure they pass)
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
At the moment, you can only scale one application. I'd like to implement a way where you can specify multiple applications which you can scale individually.
At the moment, the formation type is a wildcard field. This should not be the case. When creating new Slots, we should validate with Heroku that this type of formation actually exists or not.
The reason why web
and worker
- the 2 most used formation types - are not
hardcoded is that you could actually use different names for these, like
urgentworker
.