Insights on Ruby, Git, jQuery, Cappuccino, WordPress, Debian and OS X. Please subscribe if you find something useful!

3 Reasons Why Heroku is a Game Changer

Posted: May 26th, 2009 | Author: Jerod | Filed under: Ruby | Tags: , | Comments

For the uninitiated, Heroku is a “cloud” (hate that term) hosting service for Ruby applications. Their claim, which I believe they have substantiated, is to be an “instant ruby platform” and their success changes the game. Here is why.

1) Microwavesque Deployment

When Heroku claims that you can deploy your Ruby app instantly, they’re pretty much not exaggerating. Seriously, you should try it. It’s so fast I had to ignore my spell-checker and describe it as microwavesque. Remember when microwaves first hit the scene and people couldn’t believe how fast they could “deploy” a meal? Yah me either, but the microwave changed the game big time.

If you haven’t tried deploying a Rails app to Heroku, just go do it. Here are the steps from start to finish:

rails myapp
 cd myapp
 git init
 git add .
 git commit -m "my new app"
 heroku create myapp
 git push heroku master

If that looks like too much work for you, have Remi walk you through it in this nice screencast.

2) Drag To Scale

Scaling is a problem we all want to have, but few of us do. The rest of us spend way too much time thinking about it. With Heroku’s architecture, you don’t have to think about scaling. You just do it. If you’re fortunate enough to have your app featured on TechCrunch, Slashdot, Digg, HN, Reddit, etc, etc, you simply log in to the Heroku admin panel and “crank your dynos” (love that term) to handle the load. How do you do that? By dragging a little bar vertically. How’s that for a learning curve?

dyno

Note: This isn’t the only way to ensure your app scales. You should still optimize your code for performance, but Heroku takes care of all the server configuration (compression, caching, memory allocation, etc) and you just ask for more power when you need it.

3) Rack Support

Heroku isn’t just a Rails platform, it’s a Ruby platform. They support any Rack-enabled Ruby app. Check out how many Ruby web frameworks have Rack adapters:

  • Camping
  • Coset
  • Halcyon
  • Mack
  • Maveric
  • Merb
  • Racktools::SimpleApplication
  • Ramaze
  • Ruby on Rails
  • Rum
  • Sinatra
  • Sin
  • Vintage
  • Waves
  • Wee

That’s a long frickin’ list! Developers can pick the right tool for their need (or write their own Rack-enabled app) and not have to worry about deployment gotchas.

For example, I wanted a way to quickly resolve the public IP address of any machine I’m using (including servers) so I wrote and deployed this trivial Sinatra app in less than 5 minutes.

# public_ip.rb
require 'rubygems'
require 'sinatra'
 
get '/' do
  raw = @request.env["REMOTE_ADDR"]
  raw.match(/^(\d+\.\d+\.\d+\.\d+),?/)
  @ip = $1
  haml '=@ip'
end
# config.ru
require 'public_ip.rb'
run Sinatra::Application

The rackup file (config.ru) tells Heroku to use Sinatra to run my application. Rails would have been overkill for this, don’t you think? (Heck, Sinatra may be overkill too. You could probably write a raw Rack application in even fewer LOC, post in the comments if you have a better solution).

UPDATE: Blake Mizerany provided a few shorter examples here.

So

What Heroku offers Ruby web developers is instant deployment, fast & easy scaling, and vast tool selection. Now we can concentrate on building our applications and forget the tedious deployment and server administration tasks that used to strangle our productivity. We can deploy fast, scale quickly, and adjust to circumstance as needs arise. The game is changing, and Heroku (and others like them) are changing it.

**disclaimer**
I am only affiliated with Heroku as a customer, and receive no recompense from the ridiculous amount of props I’m throwing their way. They do have a few drawbacks, one that is a show stopper for many apps, which I will detail in a future post.


  • egocks
    so where's that "future post" of yours? can't wait to read it...
  • That is a ridiculous statement indeed. Many sites scale with Rails on the front end. See Twitter, Github... You are stuck on some FUD blog post from 3+ years ago, and clearly have no clue.
  • Mark, what is the ridiculous statement? It kinda looks like your comment is a reply to mine (in terms of indentation), but not the content.
  • Is the show stopper SSL?

    Just a guess. In any case, I'm digging Heroku. Just deployed a pre-alpha app. SO easy, even a newb like me can do it.

    http://madison.imby.info
  • Yes, lack of SSL support for non heroku.com domains will cause many potential users to find other hosting solutions. There are a few other problems, but this is the show stopper for many.
  • SSL is available on Heroku now
  • I know you can do SSL for *.heroku.com apps but not on custom domains. Has that changed recently?
  • It hasn't changed. SSL for [appname].heroku.com is the only option.
  • Not anymore, they've added a few options. Full SSL without warnings for any of your clients is expensive though, since they're running on a "cloud".

    http://docs.heroku.com/ssl
  • There is a change on this front as well: you can host multiple apps under one multi-domain SSL certificate (and one pricey Custom SSL addon). Here's how to do it: http://wojciech.oxos.pl/post/277669886/save-on-...
  • Here are the alternatives that will run on Heroku. One is a Simple Rack app and it's Sinatra equivalent (simplified version of your example). Although they are about the same complexity; I would stick with Rack on such a simple app. http://gist.github.com/118217
  • Thanks Blake, very cool! Love the brevity of the Rack version.
  • Jerod, I'd be interested in any more apps/experiments you might be running on Heroku - after spending almost a whole day fixing a production slice on SliceHost (they're a great company, I'm definitely not blaming those guys for the deployment complexities of the Rails app I produced), anything that streamlines Rails deployment is very appealing.

    Heroku is one tool I've been meaning to try for yonks, and now I'm really tempted; the one thing that's holding me back is a lack of understanding of what's possible on their platform. For example, I wouldn't be able to use Thinking Sphinx or Workling/Starling yet, would I? Is there a Heroku client list anywhere?
  • Neil-

    I have a few other apps running on Heroku. Two are Sinatra apps and the other is a Rails app. The Sinatra apps are:

    http://www.liltompeep.com
    http://www.shipitb2b.com

    The Rails app is just a proof of concept:

    http://www.buckwuck.com (test:test)

    The Heroku platform does have a few constraints (which I plan to write about in detail in a coming post), and yes Sphinx is not an option right now, but they document what you can and cannot do very well here.

    Hope that helps.
  • deno
    I'm no fan of ruby but it _does_ scale. Well, why shouldn't it? Twitter is using Rails.
    Altough they're switching to Scala because of Ruby's green threads, but heck - if your app is not as big as twitter stop worrying about scaling! You have more important things to worry about.
  • aaaaaa
    Throw as many servers as you want at Ruby, it will NEVER scale properly. This has been proved time and time again.
  • Wow. What a ridiculous statement, and not worthy of a rebuttal.
  • polypus
    utterly retarded is more like it
blog comments powered by Disqus