Rails Hosting with Hatchbox — Easier than Heroku, As Flexible as Digital Ocean

How I learned to stop trying to manage my server and ‘Have it all’.

Managed, well priced, flexible.

A++ SSL rating, HTTP 2, Sidekiq, Redis, Mysql or Postgres.

All with minimal effort from me!

I have been hosting rails websites for about 15 years.

Back in the day, I rented a physical server in a datacenter and managed that myself.

Then came the rise of the VPS and I switched to Digital Ocean. They have great tutorials on how to set up a Rails server, and nothing beats the flexibility of running your own server.

Inevitably though, things go wrong. Things get out of date, updates don’t work and I lose days rebuilding and upgrading my servers.

When I started running a serious website on Rails, I needed proper backup recovery, and a way to rebuild quickly if I needed to recover from a disaster. I spent days learning how to write chef scripts so that I could automatically rebuild and migrate to a fresh server if needed.

Frankly, that’s a lot of work, and options like Heroku make a compelling pitch to take that work away.

But Heroku gets expensive very quickly, particularly with add-ons like a bigger database, and Redis. Not to mention that it doesn’t support a whole bunch of useful gems like whenever and doesn’t support HTTP/2 at all.

Hatchbox is the holy grail!

When I read about Hatchbox, I was suspicious. However I have been using it for months now and have migrated all my Rails sites over to use it.

I’m an evangelical convert!

Hatchbox doesn’t provide hosting. Instead, they manage your chosen hosting provider. I use Digital Ocean, but you can use Linode, or any other custom server.

A $10/month Digital Ocean droplet will run a small rails site* without blinking. My $20 droplet runs 5 sites easily.

Hatchbox configures creates and configures a server to provide the following

  • My choice of database (I use mysql, but postgres is also supported)
  • SSL (A+ rating from SSLLabs) using a free LetsEncrypt certificate
  • HTTP 2 support (your site works faster!)
  • Redis
  • Cron (use whenever to schedule jobs)
  • Sidekiq
  • Basic Database Backup

Hatchbox can even build you a cluster with a load balancer (though I have never used that)

Easy Setup

There is a simple GUI to define the features you want.

Click create and Hatchbox spins up the magic, creates the server and provisions it. This takes a few minutes.

Easy Deployment

Once your server is up, you can link to a git source. I use Bitbucket. Gitlab and GitHub are also supported, or you can use a custom source.

Pick a branch to use as your deployment branch and click deploy. Hatchbox copies your code over, and runs the steps to deploy it. (It works a lot like Capistrano). Gems are installed, DB migrations performed and everything ‘just works’.

I suggest turning on automatic deployment. This means that in future, whenever you push an update to your deployment branch, it will be automatically deployed to your server.

That’s it!

The absolute joy of Hatchbox is that it takes care of things from here. Security updates on your server are processed automatically. You push updates to git and they magically appear in production.

Setting up a staging server is super-simple. Just add an extra app (potentially even on the same VPS) and deploy it from a different git branch.

And the price is good!

Hatchbox charge from $29 per month.

That gets you management for unlimited apps on two servers.

On top of that, you pay for the hosting server.

$10/month gets you a good starter server at Digital Ocean. Easily good enough to run staging and production for a medium-sized site.

That’s $39/month for a powerful managed setup

I’m delighted with the result. I think it is absolutely the best way to get started with hosting rails. I think it will serve you well until the day you hire your own server administrator!

You have a server that can expand easily without becoming ruinously expensive. You can handle any gems you need, and you don’t have to be a server administrator.

Give it a whirl, let me know what you think.

Update May 2020

Revisiting this article, I just wanted to add that two years later I’m still loving Hatchbox.

I now have 4 servers running (Hatchbox calls them clusters)and 11 apps. Several of those apps also have beta/production versions running.

I have occasionally hit some minor glitches in the site. Chris (who runs Hatchbox) has always got back to me very quickly with responses/suggestions/fixes. About half the time, the issues have actually been my mistakes in my rails app and nothing to do with Hatchbox!

I haven’t had any server battles at all. That’s a huge win.

*my small rails site handles about 25k requests/day. The $10/month, 2GB droplet uses about 60% memory and about 2% cpu.

I have used my referral links for Digital Ocean and Hatchbox in this article. If you click on them, I get credit or cash. If you’d rather avoid that, just google the links directly.

Photo by Adam Miller on Unsplash

Photo by SpaceX on Unsplash

Mobile developer since before there was an iPhone. I use Rails to run server-stuff.