0

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

debashish
  • 1,374
  • 1
  • 19
  • 29

1 Answers1

1

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

Andrea
  • 145
  • 1
  • 3
  • In case 1, if any dyno, including paid ones, gets restarted arbitrarily (by terminating the request), won't this be of concern to users? Or do only free dynos get restarted daily? – debashish Sep 16 '19 at 04:07
  • Cycling applies to all dynos. Generally, to mitigate the effect it's possible to either enable [preboot](https://devcenter.heroku.com/articles/preboot) on the Common Runtime (not available for free/hobby dynos anyhow) or using Private Spaces that adopt a [Rolling](https://devcenter.heroku.com/articles/private-spaces#rolling-deploys-with-zero-downtime) feature on restart/deploy. Your App should manage restart in a way that allows a quick shutdown and a fast restart, especially on the Common Runtime the dyno restart is really fast. – Andrea Sep 16 '19 at 05:42
  • Otherwise, you could force the restart of the App on a specific unavailability window (e.g. when no or few users are connected) before the 24h cycling period is triggered, as this will reset the cycling counter. – Andrea Sep 16 '19 at 05:42