Reputation: 1565
I'm using Ebean in Play Framework 2 for storing some basic information. This application is pushed to Heroku. Everything seems fine, I can write/read with Ebean, but after few hours, when I access application, everything that was stored is gone.
From this source I know that when application is not accessed frequently, it needs to start. That means, running application is shut down after being idle for some time, right?
Rarely-accessed free apps take a few seconds (sometimes longer) to start up — upgrade to a paid plan if you need your app to respond quickly even the first time it’s accessed in a while
I found this question No permanent filesystem for Heroku? that explains no permanent filesystem on heroku.
So, Ebean stores data on filesystem, which means they get erased after while because of no permanent filesystem on Heroku.
I should mention that I'm using free application on Heroku. Any suggestion how to solve this? Maybe I'm missing some configuration, or something...
Edit
I use H2 database saved in file.
Upvotes: 3
Views: 883
Reputation: 21564
From the heroku docs:
Apps that have scaled the number of web dynos (dynos running the web process type) so that only a single web dyno is running, will have that web dyno idled out after one hour of inactivity. ... Apps that have more than 1 web dyno running are never idled out. Workers dynos are never idled out.
And about filesystem lifecycle:
Ephemeral filesystem
Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted.
So, since you use H2 with a file stored on the filesystem, the data will be lost after one hour of inactivity.
To store your data, I strongly advise you to use the Postgres Heroku addon, which provides 10.000 rows for free.
Upvotes: 0
Reputation: 55798
Why don't you use Heroku's Postgresql available in your free plan?
There was some questions about using it in last few days, so you should have no problems with configuring it ie: https://stackoverflow.com/a/12196800/1066240
Upvotes: 0