Friday nerdery: .slugignore for Heroku deploys
Well geez, that’s nice of you, Heroku :)
The ‘Cache-Control’ header is your friend on Heroku
FourthSegment has a bunch of static pages that were loading too slowly. We hadn’t really put much thought into caching, so I thought I’d spend an hour speeding things up. Here’s what I came up with.
I added this method to ApplicationController to be used as a before_filter:
This tells Heroku’s Varnish layer to cache the content. The ab results testing out the homepage speak for themselves.
Before:
After:
#winning.
My final gripe w/ Heroku has been solved: Release Management
Anyone that has maintained a “fer realz” web app knows that the release management is nothing to be taken lightly.
The common workflow for deploying goes something like this:
- Qualify that master is ready to be deployed
- Cut a release branch from master
- Deploy that branch to production
Days and weeks will go by, and you will continue to advance master with new feature and bug fixes. If a critical bug is found in production, the process to fix is simple:
- Put the fix in master & verify
- Cherry pick that commit into the release branch
- Re-deploy release branch to production
Everybody wins. You get to fix production without pulling your new and possibly not ready features from master into the fold.
In Heroku, you just push your git repo to their remote, and they deploy your app. When pushing to Heroku, they will deploy whatever is on the master branch.
Sounds great, but the classic release management process breaks if you have a staging app also running on Heroku, because they both want to deploy off of master. For example:
- Deploy master to production
- Build new features in a dev branch
- Merge them to master so that you can deploy to staging
- Find critical bug in production
- …?
The problem here is that master is now littered w/ the features that are on staging. What’s a guy to do?
Well, one my favorite humans (who apparently knows git better than I do) not only figured it out, but wrapped it up in a little Rake script for all our benefit.
Michael Dwan wrote this blog almost a year ago, where he solves the problem of release management in Heroku. At it’s core, it’s just a git trick. Instead of:
git push staging # <— staging is your heroku staging remote
git push heroku # <— heroku is your heroku production remote
Michael figured this out:
git push staging +edge:master #<— where edge is some local branch
The +edge:master part says “Hey, staging, I’m gonna trick you into thinking that the branch called edge is really master, so use that instead.”
Now you can pick a production and a staging branch, use any other branch (including master) however you want, and not worry about being stuck in a situation where you cannot fix a critical production bug.
He wrapped all this up in a handy set of rake tasks and even put some provisions in place to prevent you from accidentally deploying the incorrect branch to production.
Brilliant. Thanks Michael. You rock.
The new eVite is on App Engine
This is impressive.
If you think that restricted hosting environments like AppEngine and Heroku cannot handle complex, large-scale web applications, think again.
Applying Unix process model to web apps
I’m continually impressed by people that can synthesize a problem and articulate the main points in writing. An art I strive to master….
