'1. I currently have 1 worker dyno doing background work. I does so every day for about an hour. The rest of the time the worker dyno recognizes, that it has nothing to do and terminates. The dyno manager will respawn the dyno and after a few seconds the dyno will terminate.
It is not clear to me how this will count in computing hours, esepecially as
https://dashboard.heroku.com/account
Shows "Not available" in the current usage statistics.
The Scheduler addon doesn't seem to be the right tool for me, as they are meant for to schedule short running background tasks (according to the description)
Q1: How does a crashed worker process consume dyno hours?
'2. How is my web app being charged when idle? The documentation says "A web dyno that is idled continues to accrue usage. To stop accruing usage, you must scale the web dyno to 0". This means that an idle web app is using the same dyno hours or at a reduced rate? "continues to accrue usage" would suggest some lower rate but isn't clear out of context.
Q2: To what rate does an idling web worker consume dyno hours?
For my understanding: Heroku does not differentiate between the Dyno types when it comes to pricing. An idled Dyno will produce the same cost like a running Dyno. But Heroku says on their website: "... Workers dynos are never idled out."
A crashed Dyno will constantly try to restart with a 10 minute break (after restart fails twice in a row).
Related
I need to be able to run my Heroku app 24/7 even when no one is currently viewing it. It's primarily a server side application that I need to constantly be running at all times.
What's the cheapest and best way to go about doing this. I don't mind paying as long as I'm not paying unnecessarily.
Thank you.
You have three options:
Hobby subscription
Free Web Dyno
Free Worker Dyno
(1) Go for the Hobby subscription: 7$ per month, the Dyno is 24/7 up and running
(2) Use the Free tier, register a valid credit card which gives you extra free Dyno hours (total of 1000 hours) and make sure the Dyno is always up.
The Free Web Dyno sleeps after 30 min inactivity (ie no incoming requests for 30 minutes): you can prevent this sending a request (from an external tool or script) every 20 min.
(3) Use the Free tier (again register a valid credit card to be eligible to 1000 free hours) with a Worker Dyno only (free worker dyno do not sleep)
More info at Free Dyno Sleeping
I have a website hosted on heroku. Whenever I load it for the first time after awhile (I haven't figured out the exact interval yet, be it days or hours), it takes upwards of 15 seconds to load. Subsequent loads are <1second, even if I clear the cache completely and open it in an incognito tab.
Why might this be? It almost seems like some kind of DNS issue but I haven't really got a clue. I don't know how to troubleshoot something like this. The situation seems to be the same even on other computers at other locations.
Quoting the Heroku docs:
If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep.
When the dyno receives traffic again, it will take a few seconds to wake up, hence the delay you've experienced.
Note that the Heroku free tier also has a maximum number of dyno hours per month. A sleeping dyno doesn't use any hours, but it does when it's active. When the hours are used up, the dyno won't wake up to incoming traffic.
You can see your remaining quota of dyno hours with:
$ heroku ps -a <app name>
Heroku suggests upgrading to a hobby dyno if your app needs to be permanently accessible. More info on https://devcenter.heroku.com/articles/free-dyno-hours
On the free tier, Heroku dynos go to sleep if they aren't used after an hour or something like that. They take a few seconds to wake up. Pay for the service and it stops happening, or write a script to ping your site every couple minutes or something.
If I only have one active app is it possible that it could spend all free Dyno hours quota?
My app is a PHP process which is always active (while (true) { do_something}). I launch this process as a worker.
I thought the free Dyno hours quota were like real hours so you can spent 24h as max per day. But if I view my remaining free hours quota in two consecutive days using 'heroku ps -a app' command then I get that I am spending more than 24h per day.
Another question, how many hours do you have in a Hobby plan?
If you are running 2 dynos (for example, a web dyno and a worker dyno), they will each use 24 hours, for a total of 48 dyno hours used in a day. Of course in reality it would probably be less than 24 hours each, if the dynos slept for part of the day.
I solved my problem disabling the web Dyno.
Is it possible to stop a Heroku Daily Dyno Restart for a Hobby Dyno?
My Goal is to stop the Dyno from restarting.
In short, No (with an aside that the restart shouldn't be seen as a bad thing).
From the Heroku Dynos and Dyno Manager Docs
Dynos are also restarted (cycled) at least once per day to help maintain the health of applications running on Heroku. Any changes to the local filesystem will be deleted. The cycling happens once every 24 hours (plus up to 216 random minutes, to prevent every dyno for an application from restarting at the same time).
Cycling happens for all dynos, including one-off dynos, so dynos will run for a maximum of 24 hours + 216 minutes.
In addition, dynos are restarted as needed for the overall health of the system and your app. For example, the dyno manager occasionally detects a fault in the underlying hardware and needs to move your dyno to a new physical location.
Additionally, Dynos Restart if you:
create a new release by deploying new code
change your config vars
change your add-ons
run heroku restart
With Hobby Dynos, the real issue is that inactivity causes the Dyno to sleep throughout the day. From my personal experience, waking up a sleeping dyno can cause a page to take ~30s to load.
There are many solutions to 'ping' the dyno on regular intervals to keep it 'awake'.
An example solution for a Node Server is heroku-self-ping
Is heroku's free 750 hours separate per app, or is it a total of 750 hours shared across all your apps?
From their site:
"Each app you create has free access to 750 dyno-hours per month and a starter-tier database."
However, from another answer on StackOverflow:
"Heroku provides, for free, 1 dyno. A dyno is an instance of your application running and responding to requests. If each instance of your application can serve each request in 100ms, then you get 600 requests/minute with the free account."
Based off of what it says there and my experience it's per app. That's talking about instances of dynos not apps. "If each instance of your application can serve each request in 100ms, then you get 600 requests/minute with the free account."
Each app you create within Heroku gets 750 dyno-hours per month for free. The number of requests your app can receive depend on the configuration of the app. For example, an app running unicorn can handle more requests than an app running something else, as unicorn can run multiple workers per dyno.
I've personally run an app on Heroku with 3 unicorn workers on one dyno, 24 hours a day, all month, and always been free (because that is ~750 dyno-hours).