schedule number of web dynos by time of day

Viewed 1568

Is there a way to use the Heroku scheduler to start and stop web dynos for specific periods of the day? Like say during business hours 2 dynos and at night only 1 dyno?

I really would like to avoid putting the normal user/pass credentials into the app itself, so I'm looking for a secure way to do this (apart from doing it manually each day for each app). Using the "heroku ps:scale web=2" directly would naturally be nice but as far as I know this is not supported.

Thanks for any feedback in advance...

3 Answers

Easy to do now with heroku addon plugin crontogo https://elements.heroku.com/addons/crontogo

Note: This is a paid plugin, and available only in US/Europe regions as of Oct 2021

Refer https://crontogo.com/blog/how-to-schedule-heroku-cli-commands/

Setup 2 jobs

1st Job “Dyno scale down” :

Cron expression: 0 18 * * 1-5

Command: heroku dyno:scale web=1:Standard-1X

This job will run on weekdays (Monday to Friday) at 6pm and scale the app down to 1 Standard-1X dyno.

2nd Job “Dyno scale up” :

Cron expression: 0 9 * * 1-5

Command: heroku dyno:scale web=2:Standard-1X

This job will run on weekdays (Monday to Friday) at 9am and scale the app up to 2 Standard-1X dynos.

Related