Yahor Yahor - 23 days ago 6
Python Question

Django: sudden DB reset after Heroku sleep

I have a very easy Django application (Pull app from Django tutorial) run on SQLite database and hosted on Heroku.

It works fine but for some reason the questions are reseted to initial state every time Heroku awaken from the idle state (I have one dyno). I can remove questions, add new ones but after reset there is initial set of questions.

How can I prevent the reset and what is the reason?
I'll appreciate any help.

Answer

Heroku dynos have an ephemeral filesystem (https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem). Since you are using SQLite which is actually a file on the filesystem, everything will run smoothly until the dyno running your application needs to restart - so its filesystem will be reset and you'll lose everything !

To avoid it just configure your application to use Heroku-Postgresql.