A little less than a year ago, I built Burplist, a free search engine for craft beer in Singapore. Intending to keep my infrastructure cost as low as possible, I started with Heroku Postgres free tier.
With a row limit of 10,000 and a storage capacity of 1 GB, I thought that it would last me for at least a year — it didn’t.
Despite having a garbage collector service that runs every week to remove staled rows, Heroku Postgres’s free tier simply wasn’t enough. I started looking for alternatives.
TL;DR: I’ve migrated my side projects’ PostgreSQL to Railway because of its pricing and ease of migration.
Heroku Postgres Alternatives
After some Googling, I came across a couple of PaaS similar to Heroku, each with its own Postgres offerings:
One stood out
I chose Railway because it makes the most economical sense for my use case. Below are some of the things that I like about Railway:
- Incredibly generous pricing, where you would only start paying for resource usage after $10. In my case, this is a lot cheaper than using Heroku.
- They have a Discord community where you can easily get help from.
- Rather slick and intuitive UI. On top of that, you can view and make SQL queries directly via the dashboard. Though, I would argue that using a database tool like TablePlus or pgAdmin would be much more convenient.
- The dashboard also provides CPU, memory, and network metrics on your database usage; which is unavailable on Heroku’s free tier.
How to Migrate
The migration was a piece of cake. This is easily one of the push factors that made me decide to migrate to Railway Postgres.
postgresqllocally on your machine. For E.g. if you’re on Mac —
brew install postgresql
- Make sure you can run the
- Setup a Railway account (referral link)
- Go to your Railway dashboard and create a new project and provision PostgreSQL
5 Migration Steps
- Export Heroku Postgres (reference).
heroku pg:backups:capture -a <heroku_app_name> heroku pg:backups:download -a <heroku_app_name>
2. At your current working directory, you should see
$ heroku pg:backups:capture -a <heroku_app_name> Starting backup of postgresql-encircled-90125... done Use Ctrl-C at any time to stop monitoring progress; the backup will continue running. Use heroku pg:backups:info to check progress. Stop a running backup with heroku pg:backups:cancel. Backing up DATABASE to b001... done $ heroku pg:backups:download -a <heroku_app_name> Getting backup from ⬢ <heroku_app_name>... done, #1 Downloading latest.dump... ████████████████████████▏ 100% 00:00 309.99KB $ ls latest.dump
3. In the same working directory with
latest.dump, run the following command to import your downloaded database dump to your Railway Postgres. Update accordingly with your own Postgres credentials:
# NOTE: # Keep PGDATABASE as `railway` if you want to view your tables via the Railway dashboard. # If you insist on another database name, you will have to create your own database via psql command. # # E.g.: # PGPASSWORD=$PGPASSWORD psql -h $PGHOST -U $PGUSER -p $PGPORT -d $PGDATABASE # CREATE DATABSE your_database_name; PGPASSWORD=$PGPASSWORD pg_restore -h $PGHOST -U $PGUSER -p $PGPORT -d $PGDATABASE < latest.dump
4. Verify that your data is imported correctly. To do so, you can use the
psql command as shown in the example in Step 4. Alternatively, connect to your database via a tool like pgAdmin.
5. Go to your existing apps, e.g. your Heroku app, and update the database connection URL/credentials accordingly.
I Miss Heroku Dataclip
One thing that I miss about Heroku Postgres is its ability to share query results with Dataclips. Heroku Dataclips is incredibly useful as you can easily:
- Make a SQL query via the UI
- Share the output in JSON or CSV format via a link
Once you have a sharable link to CSV, you easily import it to other SaaS such as Google Sheets. On top of that, most data processing SaaS supports CSV out of the box; this makes Dataclip incredibly useful.
Now, I’ll either have to generate my CSV on another server or pray that the SaaS that I’m using has PostgreSQL integration (hint: most don’t).
Having this said, I am still more than happy to make this tradeoff.
I’d also recommend you to check out their other offerings such as Redis, MongoDB, and also their starter project templates.
No, I’m not leaving Heroku entirely. Heroku has stood the test of time. I would expect a company owned by Salesforce to provide better reliability and stability.
On top of that Heroku’s add-ons often come in handy. Add-ons provide useful integration out of the box e.g. logging, search, and many more!
On the contrary, I can’t speak for the reliability and uptime of the Railway. Having that said, the projects that I am running allow me to take on this level of risk, and my experience so far has been great.
I’m rooting for Railway. I simply enjoy seeing competitions in the market.
Thanks for reading!