Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Thin: A Ruby HTTP Daemon That’s Faster Than Mongrel

By Peter Cooper / January 5, 2008

Thin is a new Web server / daemon written in Ruby by Marc-André Cournoyer that uses the EventMachine, Rack, and Mongrel libraries. EventMachine makes it super fast at processing network I/O, Rack makes it easy to integrate with existing Ruby Web app frameworks, and Mongrel helps it parse HTTP. So, yes, the title is slightly misleading. Thin actually relies on Mongrel, but is ultimately faster than it, even against Mongrel's EventMachine-enhanced guise.

You can get started with Thin with a simple sudo gem install thin and then you can use it with any Rack supporting Web app / framework. With a Rails app, for example, a simple thin start in the base directory will get things moving.


  1. Geoff says:

    Here's a link to the home page:

  2. Radarek says:

    For clarity: it uses only mongrel parser as we can read on Thin web "the root of Mongrel speed and security".

  3. FrankLamontagne says:

    Marc-André Cournoyer is a prolific contributor for the Rails community. I suggest everyone to start following him on his blog :

  4. Stephen says:


    Here's a quick rake task to make a thin cluster:

    rake thin:cluster:start
    rake thin:cluster:stop

    For the start task, you can pass in the RAILS_ENV and the SIZE of the cluster (default 4).

    rake thin:cluster:start RAILS_ENV=production SIZE=10

    namespace :thin do

    namespace :cluster do

    desc 'Start thin cluster'
    task :start => :environment do
    `cd #{RAILS_ROOT}`
    port_range = RAILS_ENV == 'development' ? 3 : 8
    (ENV['SIZE'] ? ENV['SIZE'].to_i : 4).times do |i| do
    port = "#{port_range}%03d" % i
    str = "thin start -d -p#{port} -Ptmp/pids/thin-#{port}.pid"
    str += " -e#{RAILS_ENV}"
    puts "Starting server on port #{port}..."

    desc 'Stop thin cluster'
    task :stop => :environment do
    `cd #{RAILS_ROOT}`
    port_range = RAILS_ENV == 'development' ? 3 : 8"#{RAILS_ROOT}/tmp/pids").each do |file| do
    if file.starts_with?("thin-#{port_range}")
    str = "thin stop -Ptmp/pids/#{file}"
    puts "Stopping server on port #{file[/\d+/]}..."


  5. macournoyer says:

    I swear I posted a comment yesterday!?

    Thx a lot Peter for talking about my project.

    Just to be clear, Thin doesn't depend on Mongrel. But the Thin parser is a fork of the excellent Mongrel parser, customize for greater performances with Rack.

  6. Robert Dempsey says:

    @macournoyer: how is the memory use with Thin (i.e. Thin taking up memory as time goes on)? Thanks.

  7. McD says:

    I create a new Rails project and run thin with:

    rails depot
    cd depot
    thin start

    Then I browse to http://localhost:3000 I get this rrouting error:

    no route found to match "/" with {:method=>:get}

    If I start mongrel:

    I get the typical "Welcome Aboard" Rails page.

    What's missing in my process to use thin for the webserver?
    I may be back a rev on Rails fro example.

  8. macournoyer says:

    @Robert: Thin takes a little less memory then mongrel since it doesn't use threads.

    @McD: yeah, that url rewriting part hasn't been implemented yet, it's on the TODO list though :) So page caching and the /index.html page won't work for now but the rest should.

  9. Derek says:

    I hope the Ruby/Rails sharks don't cause Marc-André Cournoyer to become unemployed and homeless.

  10. Floyd Price says:

    Maybe this new competition will force *** back into mongrel development?

  11. Pingback: Rails Magnet

  12. Mark says:

    lol @ Derek... literally too, thanks for that :)

Other Posts to Enjoy

Twitter Mentions