Search code examples
herokuheroku-cli

How Heroku dyno hours are calculated?


I created a free Hobby account with 550 dyno hours. I'm running a Python script which contains a scheduler to run the program from 9:00 to 10:00 AM daily. For the rest of the time, my script does nothing but Heroku is consuming dyno hours for idle time.

I'm running worker service in Procfile, how to make script sleep other than schedule time? so that dyno hours can be saved. As there are only 550 dyno hours which means my script runs 3 weeks only.

Thanks for your suggestion.


Solution

  • One option is to create a Web Dyno together with your Worker.
    The Web Dyno sleeps after 30 min inactivity (no web traffic in a 30-minute period), and will also send to sleep the associated Worker.

    You can wake up the Web Dyno with a simple HTTP call (an endpoint) at 09:00 which will start the Web and the Worker. Your worker will start the scheduled script and eventually go to sleep again.
    You effectively are going to use only few hours a day.

    BTW if you add a valid Credit Card you can get an extra 450 hours free, you will not be charged for the entire 1000hrs. Heroku is reliable (in my opinion) you wont get surprise charges unless you start adding plugins or other connectors.