Upgrade process on Heroku? - heroku

If I update an application running on Heroku using git push and this application is running on multiple dynos - how is the upgrade process run by Heroku?
All dynos at the same time?
One after another?
...?
In other words: Will there be a down-time of my "cluster", or will there be a small time-frame where different versions of my app are running in parallel, or ...?

well can not tell the internal state but what i have experienced is
Code push complete
Code compiled (slug is compiled )
After that all dynos get the latest code and get restarted. (restart take up to 30 seconds or so and during this time all requests get queue).
So there will be no down time as during the restart process all the requests get queued and there i dont think that that multiple versions of your code will be running after the deployment.

Everyone says there's 'no downtime' when updating a Heroku app, but for your app this may not be true.
I've recently worked on a reasonably sized Rails app that takes at least 25 seconds to start, and often fails to start inside the 30 seconds that Heroku allows before returning errors to your clients.
During this entire time, your users are waiting for something to happen. 30 seconds is a long time, and they may not be patient enough to wait.
Someone once told me that if you have more than 1 dyno, that they are re-started individually to give you no downtime. This is not true - Heroku Stops all dynos and then Starts all Dynos.
At no time will there be 2 versions of your app running on Heroku

Related

Will Heroku dyno automatic restarts kill running processing on my application?

I have an application that is hosted on Heroku. The application has a process that is run on the server, that the user has the ability to start and stop. Once the user clicks 'Start', the process is supposed to stay running until the user presses 'Stop'. The functionality of the app should allow that the process can be run for extended periods of times (6 months or so) continuously.
I have deployed my app on a Heroku free dyno. While reading the Heroku documentation, I came across this page that states that Heroku Dynos are restarted automatically every 24 hours. Here is the relevant passage:
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). Manual restarts (heroku ps:restart) and releases (deploys or changing config vars) will reset this 24 hour period. Cycling happens for all dynos, including one-off dynos, so dynos will run for a maximum of 24 hours + 216 minutes. If you have multiple dynos, they should cycle at different times based on the random 0 to 216 minutes difference. If you continually make changes to your application without a 24 hour gap, you won’t see cycling at all.
Does this mean that the user process that he/she has started will automatically be stopped when the dyno restarts? If yes, does it automatically resume the user process where it left off?
If not, I will have to find a different hosting solution since the process may need to be run 24x7x365.
Does this mean that the user process that he/she has started will automatically be stopped when the dyno restarts?
Yes it does. As it will when you change config variables, or deploy updates, or add / remove addons.
If yes, does it automatically resume the user process where it left off?
No it doesn't. Any safe-and-resume behaviour you have to implement in your application. When stopping processes, Heroku will send them a SIGTERM signal and give them 30 seconds to safe their work.
If not, I will have to find a different hosting solution since the process may need to be run 24x7x365.
I doubt that there is any hosting solution that will give you what you want. In a cloud environment restarts are a thing that happens all the time, at least for you updating your application, bugfixes, security fixes. Every hosting provider or platform that provides you with 24x7x365 uptime will also restart and replace your dynos all the time.

Heroku: Prevent worker process from restarting?

I have a Heroku worker setup to do a long running job which iterates over long periods. However whenever I do an update & deploy of other files in the repo this worker restarts, which is annoying, any way to avoid this?
No. This behaviour is part of Heroku's Automatic Dyno Restarting.
You can't work around this. Instead, you need to build all parts of your app to be able to function properly despite the fact that all dynos will restart at least once every 24 hours or so, whether or not you deploy updates in your repo.
Most significantly, you need to build support for Graceful Shutdown into all your processes (e.g. web process and worker processes).

Issue with Heroku's production configuration: a set of two dynos takes 8 seconds to respond

I have an interrogation regarding Heroku's dynos.
As of now my app runs two 512MB dynos and I was pretty certain that this configuration, i.e. more than one dyno, ensured that the container's application was started and ready to serve clients.
However, I frequently notice that the dynos are not always started and it takes something like 8 seconds to load the app. See screen shot below. The host XXXX.herokuapp.com spends nearly 8 seconds in "waiting".
Has anyone else experienced such issues with Heroku? How can they be resolved?

Is there any down time when committing to a clojure app running on Heroku?

Is there any potential downtime when I do a commit to a clojure/Java app running on Heroku?
I am guessing not - but can't find out for sure.
Thanks.
When you push to Heroku, you invoke the slug compiler, which does all the heavy lifting needed to turn your application into a self-contained archive. That can take a little while, as you see whenever you run git push. However, during this time, your application is running normally.
When your slug finishes compiling, Heroku then pushes it out to the dyno grid. This causes existing web dynos to stop and causes new ones to start. Your application will be unresponsive between the time that the old dynos stop and the new ones begin serving requests -- probably only a few seconds. During this interval, Heroku's routing layer will queue incoming requests.
TL;DR: users might notice a pause (but not an error!) as your application is updated. You can simulate this at any time by running heroku restart.

Heroku Dyno... Running Schedule tasks without a Worker

I have recently added "Heroku Scheduler" addon to my heroku app...
I currently have a free heroku account and have the standard one web dyno....
Now I have set up a scheduled comment to run with scheduler... What will happen if I keep having 0 Worker dynos....
Do I get charged?
Does my task just not run?
Or does it fall back to the web dyno and gets queued on that one?
Your scheduled task with scheduler will run when you tell it to. It is similar to a worker process, however it runs then stops running once its finish instead of continually being billed. You are billed for the time it runs, but only that time. If your task is a short task running for 1 minute, on an hourly basis then you'd be billed at 24 minutes a day.
Just as an update to my previous comment, all the above as been obviated by the recent dyno and billing changes on heroku. You can now have a free web+workder dyno, provided it sleeps for at least 6 hours per day. There are also other changes making it cheaper to run a small hobby type project, even 24 hours per day.
https://devcenter.heroku.com/articles/usage-and-billing
As Craig mentioned, the scheduler addon will run a task for a set amount of time. It will use the time from your web dyno and it will not spawn a new dyno to complete the task. As a result, your web traffic will be queued during that duration (this is my current understanding of using the scheduler addon for heroku).

Resources