Search code examples
heroku

Ephemeral filesystem and dynos restart


I'm new to heroku and have 2 questions:

  1. heroku uses the Ephemeral filesystem. So if I deloy php + nginx + mariaDB + docker into heroku (the database already has website data before). And after a day, heroku will restore the data to the last deloy. Does that mean that the data written to the database during the day will be deleted, but the data of the previous database (at deloy time) will remain the same?

  2. One day dynos will restart once. If my python program is in progress in step 3, will it have to start over (from step 1)? Or if my website is running, it will be down for a short time every day?

Thank you. This will help me plan ideas and prices.


Solution

  • does that mean that the data written to the database during the day will be deleted, but the data of the previous database (at deloy time) will remain the same?

    In your case, yes, if you are running maria db as part of the same Docker image. The Heroku model requires any persistent storage to be held outside of the dyno - usually this means using a database add-on. There are several free options to try this out with.

    One day dynos will restart once. If my python program is in progress in step 3, will it have to start over (from step 1)?

    Again, yes. If you have long running processes, it's better to move these to a background job server or scheduled task. You can delay shutdown for 30 seconds by intercepting the unix TERM signal to allow a graceful shutdown. For longer than this, it's better to move the task to a scheduler (again, free options exist) or a dedicated background job.

    Or if my website is running, it will be down for a short time every day?

    Restarts on Heroku are typically very short (on the order of a second or two). Downtime can be mitigated by enabling the preboot feature which boots the replacement dyno in the background before switching requests to it.

    For a beginner the Heroku model may appear complicated, but all of the requirements are helpful in making sure an app is robust and ready to scale up if needed. You can read about the underlying philosphy by searching for "12 factor apps".