I’m Leaving Heroku Postgres. Here’s Why

I’m leaving Heroku Postgres for now. Right here’s why

Train on a Railway
Photograph by Daniel Abadia on Unsplash

Rather less than a 12 months in the past, I constructed Burplist, a free search engine for craft beer in Singapore. With the aim to keep my infrastructure cost as low as possible, I began off with Heroku Postgres free tier.

With a row restrict of 10,000 and a storage capability of 1 GB, I believed that it could final me for a minimum of a 12 months — it didn’t.

Regardless of having a rubbish collector service that runs each week to take away staled rows, Heroku Postgres’s free tier merely wasn’t sufficient. I began on the lookout for alternate options.

TL;DR: I’ve migrated my facet tasks’ PostgreSQL to Railway due to its pricing and ease of migration.

After some Googling, I got here throughout a few PaaS just like Heroku, every with its personal Postgres choices:

One stood out

I selected Railway as a result of it makes essentially the most economical sense for my use case. Under are a number of the issues that I like about Railway:

  • Incredibly generous pricing, the place you’ll solely begin paying for sources utilization after $10. In my case, it is a lot cheaper than utilizing Heroku.
  • They’ve a Discord community the place you’ll be able to simply get assist from.
  • Fairly slick and intuitive UI. On high of that, you’ll be able to view and make SQL queries straight by way of the dashboard. Although, I’d argue that utilizing a database instrument like TablePlus or pgAdmin can be way more handy.
Railway PostgreSQL dashboard
You’ll be able to solely view and make SQL queries on the default database title railway
  • The dashboard additionally offers CPU, reminiscence, and community metrics in your database utilization; which is one thing that’s unavailable on Heroku’s free tier.
Railway PostgreSQL dashboard metrics
Railway PostgreSQL dashboard metrics

The migration was a bit of cake. That is simply one of many push elements that made me resolve emigrate to Railway Postgres.

Pre-requisite

  1. Put in postgresql regionally in your machine. E.g. when you’re on Mac — brew set up postgresql
  2. Ensure you can run the pg_restore command

Setup Railway

  1. Setup a Railway account
  2. Go to your Railway dashboard and create a brand new challenge and provision PostgreSQL
Railway PostgreSQL variables
Pay attention to your database credentials below the “Join” or “Variables” tab. You’ll want them later.

5 Migration steps

  1. Export Heroku Postgres (reference).
heroku pg:backups:seize -a <heroku_app_name>
heroku pg:backups:obtain -a <heroku_app_name>

2. At your present working listing, it is best to see newest.dump file

$ heroku pg:backups:seize -a <heroku_app_name>Beginning backup of postgresql-encircled-90125... carried out
Use Ctrl-C at any time to cease monitoring progress; the backup will proceed operating.
Use heroku pg:backups:data to examine progress.
Cease a operating backup with heroku pg:backups:cancel.
Backing up DATABASE to b001... carried out
$ heroku pg:backups:obtain -a <heroku_app_name>
Getting backup from ⬢ <heroku_app_name>... carried out, #1
Downloading newest.dump... ████████████████████████▏ 100% 00:00 309.99KB
$ ls
newest.dump

3. In the identical working listing with newest.dump, run the next command to import your downloaded database dump to your Railway Postgres. Replace accordingly with your individual Postgres credentials:

# NOTE:
# Maintain PGDATABASE as `railway` if you wish to view your tables by way of the Railway dashboard.
# If you happen to insist on one other database title, you'll have to create your individual database by way of 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 < newest.dump

4. Confirm that your knowledge is imported accurately. To take action, you should utilize the psql command as proven within the instance in Step 4, or hook up with your individual database by way of a instrument like pgAdmin.

5. Go to your present apps, e.g. your Heroku app, and replace the database connection URL/credentials accordingly.

That’s it!

One factor that I actually miss about Heroku Postgres is its means to share question outcomes with Dataclips. Heroku Dataclips is extremely helpful as you’ll be able to simply:

  1. Make a SQL question by way of the UI
  2. Share the output in JSON or CSV format by way of a hyperlink

Upon getting a sharable hyperlink to CSV, you simply import it to different SaaS akin to Google Sheets. On high of that, most knowledge processing SaaS helps CSV out of the field; this makes Dataclip extremely helpful.

Now, I’ll both must generate my very own CSV on one other server or pray that the SaaS that I’m utilizing has PostgreSQL integration (trace: most don’t).

Having this stated, I’m nonetheless very happy to make this tradeoff.

Different makes use of

Apart from utilizing Railway as my PostgreSQL database server for my tasks, I’m additionally utilizing it to host my very own umami analytics web site together with Vercel.

I’d additionally advocate you to take a look at their different choices akin to Redis, MongoDB, and in addition their starter challenge templates.

No, I’m not leaving Heroku solely. Heroku has stood the check of time. I’d anticipate an organization owned by Salesforce to offer higher reliability and stability.

On high of that Heroku’s add-ons usually come in useful. Add-ons present helpful integration out of the field e.g. logging, search, and lots of extra!

Quite the opposite, I can’t communicate for the reliability and uptime of the Railway. Having that stated, the tasks that I’m operating enable me to tackle this degree of danger, and my expertise up to now has been nice.

I’m rooting for Railway. I merely get pleasure from seeing competitions available in the market.

Thanks for studying!

More Posts