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

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.

Related

Is there a way to set dyno restart time in heroku?

I deployed a to-do web service in heroku.
But I didn't know that saving file is only ephemeral.
It's still fine because my to-do is only for a day.
But I want it to be reset on 4 am to maintain the data for a day
Is there anyways to manually set dyno restarting time?
Or is there some free service which provides saving besides heroku?
It is not possible to schedule the restart time.
Using the Heroku CLI I guess you can script it (meaning your computer needs to be on all the times).
Be aware that a free Dyno goes to sleep after 30 min inactivity (no incoming traffic). Once asleep the first request will make it start again.
You should look at storing the file somewhere else (save it on Google docs or Amazon S3) so you don't lose your data if the Dyno restarts.

Heroku - Can app get recycled while it is being used?

I plan to deploy a mini web app to resize photos to the heroku free tier. I read that the heroku file system is ephemeral - uploaded files get deleted when the dyno restarts. What I want to know is if I upload an image only for a short duration to change its properties and then download it, is there a chance that it will get deleted before I download it? That is, can the app get cycled when it is in use?
Regards,
Debashish
On a free tier a web dyno gets cycled on:
1) Dyno restarting - according to the documentation
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).
Restart can happen at any time then, when occurring, also in progress web request could be terminated. After the restart is triggered, you have 30 seconds to graceful shutdown before the process gets killed
2) Dyno sleeping - according to the documentation
If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep
If your web request executes during the same session all the operations to upload/change/download the image, you should be guaranteed the file does not get deleted in the process. However, you can avoid these events using monitoring services such as Pingdom or New Relic that can prevent a web dyno from sleeping

Is it possible to stop a Heroku Daily Dyno Restart for a Hobby 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

Heroku suitable for app based on long running processes?

I have an app which requires long running processes - typically over 2 hours (recording streaming media). Based on Heroku's website, my worker server running these processes will be restarted randomly, at least once per day.
Is there anyway to control/avoid these restarts, so as not to interrupt my long running processes?
Do other paas providers avoid this issue?
I don't know, How to control/avoid these restarts. I was also going through their documentation, They clearly state that "Dynos are also cycled at least once per day, in addition to being restarted as needed for the overall health of the system and your app."
I think, Dynos restart should only take placed when system behaves unexpected or Dynos are found in crashed state OR In month or week to clear cache memories.
You can try App42 PaaS which monitors your Apps continuously to make sure that they are up and running. If any kontena is found in crashed state, Health Monitor try to bring it back to working state. if unable than that particular kontena is deleted & replaced with a new one.
Disclaimer: I work for App42 PaaS.

Upgrade process on 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

Resources