herokudyno

How does a single dyno consume hours?


How do dynos consume hours?


Solution

  • The documentation says:

    Every Heroku account is allocated a pool of free dyno hours. An app actively consumes free dyno hours if the app is set to use free dynos and any of the following are true:

    • It has a web dyno that is receiving traffic (i.e., not sleeping)
    • It has a worker dyno running
    • It has a one-off dyno running. For example, one started via the CLI or Scheduler.

    If you only have a single dyno you shouldn't be able to go over 744 hours (24 hours / day × a maximum of 31 days in a month) a month. But if you are also using workers or one-offs (e.g. via Heroku Scheduler) you could.

    When your free dyno sleeps after 30 minutes of inactivity the next request will take longer to receive a response. This is because Heroku needs to wake your dyno up.

    Yes, you can host JSON file to be requested by arbitrary HTTP clients. However, you should note that Heroku's filesystem is ephemeral. Any changes you make to the filesystem (like saving a file) will be lost whenever your dyno restarts. This happens frequently (at least once per day).

    A better solution would be to use a client-server database to store your data and build a JSON response from that data dynamically. Heroku Postgres is a simple option with a free starter tier, but there are other options too.