How to Migrate from Heroku's Free Plans (Dynos, Postgres, and Redis)
There's still time to avoid loosing your application data. Let's get prepared for the next Heroku Migration and start to migrate before November 28th 2022.
In case you missed Heroku warning emails about this migration, or you missed this warning message on your Heroku dashboard:
Yeah, I know that "losing your app's data" might be a bit dramatic, but that's exactly how Heroku is framing it:
You must upgrade to our new low-cost or other paid plans by this date to ensure your apps continue to run and retain your data
Wow, so does that mean that my Postgres will lose their data? Would I have access to previous databases backups or will they be gone as well? There are some open questions to me. The risk is high, so let's review what's going on and migrate them as soon as we can.
A bit of context
On November 28th, just a few days from now, Heroku will end some of their free Dynos and free Data Plans for Redis and PostgreSQL. This was initially announced in Heroku Next Chapter and later in a newer post about Heroku New Plans. Check those links if you want to try to understand better their reasons.
Let's review our options and what we need to do:
The Alternative to Free Dynos
Well, free dynos are no more. The closest alternative is the new
Eco Dynos Plan which consists of a $5 per month subscription plan to get access to a pool of 1000 hours of Eco Dynos. First you need to subscribe to the
Eco Dynos Plan and then you can change your free dyno types to the new Eco one.
That subscription includes 1000 hours, which might be a lot for most accounts. It is a single pool of hours shared between all the apps that we have under that account. Also, eco dynos put themselves to sleep after 30 minutes of no traffic. And if you use all of your 1 thousand hours, then all your eco dynos will simply not start anymore - at least until the next billing cycle. It may be alright for certain environments like staging or review apps, but not at all for production.
At Hashrocket, we've already moved our staging apps to use Eco Dynos. Below, we can see the current consumption in Heroku => Account Settings => Billing:
Easy way to migrate Redis and Postgres Plans
Heroku put an upgrade page easily accessed from your dashboard where they explain the "upgrade" plan:
They list to us all apps that we own or that we are linked to with the free tier services for PostgreSQL and Redis.
This seems very straightforward tool to use and it might do the job for most accounts out there.
A heads up here, we've not used this tool yet. Rather, we took a different approach: we decided to use the opportunity to bump PostgreSQL and Redis to latest versions. We'd encourage you to do the same and have more control over the upgrade process.
We like to use cli a lot, so here's the commands we used:
heroku redis:info -a my-app-staging heroku addons:upgrade CHANGE_ME_REDIS_ID heroku-redis:mini -a my-app-staging heroku redis:wait -a my-app-staging heroku redis:info -a my-app-staging
Although this process took way longer that I expected, bumping Redis was pretty simple. We just call an
addons:upgrade command and we specify to which plan we are going to, in this case I chose the $3 per month
To upgrade PostgreSQL we had to follow a slightly different approach because the
addons:upgrade command is not allowed on hobby tier plans. This way we ran:
heroku addons:create heroku-postgresql:mini -a my-app-staging heroku pg:wait -a my-app-staging heroku pg:info -a my-app-staging heroku maintenance:on -a my-app-staging heroku pg:copy DATABASE_URL CHANGE_ME_NEW_DB -a my-app-staging heroku pg:promote CHANGE_ME_NEW_DB -a my-app-staging heroku maintenance:off -a my-app-staging heroku pg:info -a my-app-staging heroku addons:destroy CHANGE_ME_OLD_DB -a my-app-staging
And here my surprise was that copying the data from old postgres to the new-ish 14.5 one was kind of fast. The maintenance mode was on for just a few minutes on the apps that we migrated so far. And as we can see, we provisioned a new pg to the
mini plan and the cost will be $5 per month. The
mini plan has a the same spec as the old
Well, the new plans are all good to go, the prices that Heroku is showing on the resources page seems wrong to me, I guess that they are still adjusting to the new plans.
I have to mention that all data migration that we did for postgres was very smooth, and we did migrate from old postgres-10 to posgres-14.5. The only issue that we had was that 1 of the apps had a very old version of the pg adapter, so we had to bump the app dependencies, but it was a very minimal change to be honest.
Migrating away from Heroku
This is also an option of course. It would require a bit more time to prepare, deploy, maybe change CI and test, but it's always something that we should consider. Although Heroku is still a good option, in the last few years many new providers have launched their services so we do have now good options to go along. If you think you do want to make the switch, we would recommend looking at render.com or fly.io. For the amount of apps we are maintaining, the right choice was to keep those on Heroku at least at this point in time.
This was a bit of the journey we've been on in the last few days. We used this time to bump our redis and postgres which was great. We also did some upgrades on the apps we were testing, and we ended up moving them to newer Heroku stacks - another bonus.
Applications require maintenance every once in a while, so it was nice to do that and put all apps in a similar position, even the ones we've not changed in years.