During Railsconf I was anxious to see what all the hype was about Sinatra.  While attending Blake's Sinatra tutorial I ported the Flickr Original web service (originally in merb) to a nice and compact one-file Sinatra app.  It's really nice having everything as minimal as possible and in one file.

Now, deployment.

Slicehost
I guess Thin is the standard for deploying Sinatra apps (when did mongrel go out of style?). Deploying with Thin just involves setting up a config.yml with your working directory, paths to your pid, log, rackup file, ports, etc and then setting up nginx (or whatever web server you're using) accordingly as a proxy.  Deploying from scratch on Slicehost wasn't too bad...but some legwork is still required.

Heroku
I also tried deploying on Heroku.  Heroku makes it dead simple to deploy an app: after setting up an account, you just need create a Heroku app which creates a remote git repo that you can push to.  git push heroku automatically updates your code and redeploys your app.

Some things to note:

  • If you have custom gems, you need to add them in a .gems file
  • You can use your own domains by pointing a CNAME record to Heroku

Heroku makes it extremely easy to get something up and running extremely quickly.  You can have as many free projects as you want, so it can be used as a quick staging server for small projects.

Google App Engine
Deploying here was quite a bit more difficult (see previous post)...I had to modify more than a couple things to get stuff working completely on the App Engine infrastructure.  Luckily jruby and  the appengine sdk provide a number of scripts to pack and deploy your app.  GAE gives a nice dashboard of different metrics (req/s, ms/req, etc) as well as stats on your current load, logs, bandwidth, and more.

How does performance compare? Running the same ab test gave these results:

Platform Requests per second Time per request (ms)
Slicehost 9.16 327.612
Heroku 7.71 389.157
GAE 4.89 614.014

Not suprisingly, my 512slice came out on top, but Heroku wasn't far behind (blossom with 1 dyno)...can't beat that for the price of free-99.  Google App Engine was only able to serve half the requests per second. So until deploying on GAE gets more streamlined, I think I'll be deploying more apps to Heroku.

4 Responses to “Sinatra deployment and performance on Slicehost, Heroku, and Google App Engine”

  1. Tom Says:

    Great post! How many thins/mongrels were you running on your 512 slice? I would be really curious to see the ab results if you use the same number of Heroku dynos as Slicehost thins, since running only one dyno/thin is bad for concurrency. As far as I know there’s no way to set the number of threads/app servers with GAE.

  2. Jason Says:

    I had two thins set up on my slice. Perhaps I’ll use my $30 Heroku credit from Railsconf towards upgrading my dynos and post an update…

  3. Flow » Blog Archive » Daily Digest for November 6th - The zeitgeist daily Says:

    [...] Shared Sinatra deployment and performance on Slicehost, Heroku, and Google App Engine | JZ * LABS – t…. [...]

  4. Heroku Overview and Performance comparisons | Simply Excited – Technology, Outdoor and Design Says:

    [...] is an interesting performance comparison of Slicehost vs Heroku vs Google App Engine for a simple sinatra [...]

Leave a Reply