Checklist for Deploying a Rails App to Heroku

August 26, 2014 David Julia

So, you wanna deploy to Heroku… It’s super quick to get something up and running, but if you want a robust, production-ready system, you’ll have to do a bit more than just git push. Without further adieu here is my checklist for things to do when getting an app ready for its first production deploy to Heroku.

  1. Add rails_12factor to your gemfile
    Rails 12 factor app will log to stdout so that heroku can see your application level logging. It also has your Rails server serve static assets since you don’t need something like Nginx to act as a reverse proxy/static file server when using Heroku.
  2. Sign up for a log aggregation service
    In order to retain logs, you must sign up for a log aggregation service that Heroku will stream your logs to. Without a log aggregation service you will be able to tail logs on a live application, but you won’t be able to see them later. There are a number of logging services available as Heroku add-ons, such as Loggly and Papertrail.
  3. Choose a robust application server.
    WEBrick, the default Rails server is only suitable for development. It can only serve one request at a time. There are a number of very good choices for an application server, Unicorn is great and is generally seen as the default choice these days. However, if you have slow clients you may consider either Puma, Rainbows or Thin.
  4. Add performance monitoring.
    You’ll want a service like New Relic for general monitoring of things like up time, heavily used/slow queries, etc. It’s always useful to know how your app is behaving in the wild.
  5. Add error reporting.
    Choose a service like Airbrake or Honeybadger so that you are notified
    when errors occur in your application.
  6. Double check your database settings and plan.
    It’s always best to make sure that you signed up for the right tier of service from
    your database provider. For starters, check that you have a big enough database. It’s also prudent to make sure that your connection pool is set high enough, and that your plan supports enough concurrent connections for your set up.
  7. Set up release tagging (and script your deploys).
    It’s vitally important to know exactly what code is running in production.
    A simple scheme for tagging releases to production is to use git tags with timestamps. It is also a must to script your deploys that way they are repeatable. An additional benefit is now, if we want to do continuos deployment to a pre-production environment, we have scripts to do that.
    An example deploy script is below:
TIME=`date +%s`
echo "attempting to push head of master to $ENVIRONMENT..." &&
git push $ENVIRONMENT master --force &&
echo "successfully pushed to $ENVIRONMENT" &&
echo "tagging head of master as deployed..." &&
git tag -a "$ENVIRONMENT/${TIME}" -m "$DATE" master &&
git push origin --tags &&
echo "successfully pushed tags" &&
echo "running migrations..." &&
heroku run rake db:migrate --app "mylovelyapp-$ENVIRONMENT" &&
echo "successfully ran migrations"

Example Usage: ./ production

About the Author


Platform Wind Tunnel, Part I: Heroku
Platform Wind Tunnel, Part I: Heroku

For well over 100 years, engineers have utilized wind tunnels to study the effects of aerodynamic forces on...

Content-Based Image Retrieval using Pivotal HD with HAWQ
Content-Based Image Retrieval using Pivotal HD with HAWQ

The number of images and videos captured by humans using digital cameras is staggering. It has been estimat...