Rails needs Active Deployment

I’ve been using Ruby on Rails for a decade now and I still love it. But sometimes it is one of those love-hate relationships. I work as a consultant aka fire fighter to help companies with their Rails projects. Most times I help them fixing all sort out performance and high availability issues. I’ve seen the code base of a lot of different Rails applications. So I don’t just see the happy path but also a lot of not so happy campers. I even wrote books about Rails to help more Rails beginners.

This is me failing to light paint a “2019” with a sparkler. Seemed to be as easy as deploying a Rails application.

It took me a while to understand and appreciate features like Active Storage, Active Job, Action Cable or the new Action Mailbox. Many times my initial thought was “There is already at least one good solution (gem) for that problem. Why reinventing the wheel?” But during my work on so many different Rails projects I began to realize that it is so much better to give each team a good to go initial set of tools. Of course they can use a different gem (like so many do for testing) but they have a very good start with the vanilla Rails project. And the more projects use the same base the better the general documentation and code quality gets. It has never been easier to find help for a Rails problem on stackoverflow.com than today. No need for fancy gems to solve standard problems. BTW: Many times those fancy gems don’t survive the next Ruby upgrade because their maintainer lost interrest or just doesn’t have time for it.

Development of new Rails projects has never been easier and faster! But …

Deployment is still a nightmare

What good is a framework if it is not easy to deploy to a production server? In the pre-Rails days many of us just copied a directory of PHP files to the web server via scp or ftp and that was it. With Rails it became more complicated.

Of course you can use Heroku which takes most of the pain out of this. Many companies do use Heroku but it is expensive and not always super fast. Many companies want to deploy their Rails application to a normal out of the box linux distribution (e.g. Debian or Redhat).

Apache or Nginx don’t do the hard lifting for Rails like they do with PHP. But you still need them. So you have to make a choice of Puma, Unicorn or whatever to actually run your Rails application and then you have to put Apache or Nginx in front of that. Or you use Phusion Passenger (which involves some fiddling around with the Nginx or Apache modules). All complicated enough for a Rails newbie. Additionally you have to use RVM or rbenv to run the needed Ruby version.

But you still have to find a way to actually copy your source code to the server, run all needed migrations and restart the server. The bravest even go so far to attempt zero downtime deployments (a little secret: You want to have a look at Phoenix Framework). So you have to dive into Capistrano or some cool new kid like Mina.

To setup deployment for a simple Rails application on Heroku takes a couple of minutes. 30 minutes tops (if you have to get the credit card information of your boss first). But the setup of a deployment process on a vanilla Linux Server from the ground up takes hours if not days. You have to read too many different tutorials and have to make too many decisions. And you end with a snow flake. Beautiful but one of a kind and hard to support.

Docker! ?

I hear all those voices which shout: Why don’t you use Docker for this? Docker makes everything so easy!

No, it does not! I challenge you to find a single tutorial which describes how to setup a Docker deployment from start to finish for a Rails application for a Debian server. Most of the how-tos are half baked at best. They just show you how to run Docker for your development system.

But don’t get me wrong: I’m all for Docker. This posting is not pro or against Docker. This posting is about a standard deployment for Rails.

But we pros know how to do it!

That doesn’t help at all. If a normal developer who maybe works on 1 or 2 Rails projects can not create a simple non-Heroku deployment to production than that is a big problem. Rails became visible with @DHH ‘s 15 minute blog video. It became visible and popular because that was so easy to accomplish. But without an easy production environment it’s worth not much.

Active Deployment

To be honest I don’t care which technology we use on the server. I don’t care how we all deploy. What I care about is that it has to be an easy to use system which comes out of the box. No more deployment snow flakes. Convention over configuration! I want to dive into an exisiting Rails project knowing that it probably uses the standard tool for deployment.

I’m calling out for DHH or any body else in the Rails community to think about this. Take a step back and realize how hard this problem is for a normal Ruby team which does not have super hero DevOps power.

I don’t have the technical knowledge to find an optimal solution for this problem. I just see the pain and it hurts me that many potential new Rails projects never get a chance just because they don’t have an easy way to deploy it to a non-Heroku environment.

Please discuss and share this.