e x p r e s s i c a

ruby on rails, business and technicalities

No public Twitter messages.

  • RSS
  • Facebook
  • Twitter
  • Linkedin

Mongrel to THIN

For Rails applications I am using THIN on my local machine since a couple of weeks and found it better than Mongrel. I’ve started replacing mongrel with THIN on servers as well. THIN leverages the best of the available resources… It uses mongrel’s parser along with the Eventmachine and the Rack Ruby libraries which together provide better speed, greater requests/sec and certainly consumes lesser memory.

Install THIN by issuing

  sudo gem install thin

THIN accepts more or less similar switches as that of mongrel. You start THIN by issuing

  thin start -p 9090 -d -e production

-p — port, defaults to 3000
-e — environment, defaults to development
-d — daemonize mode

THIN provides an in built support for clustering and running multiple servers for the same applications. You can start say 3 servers for the single application by providing the -s switch as…

  thin start -p 9090 -d -e production -s 3

And similar to mongrel it will start three servers on the ports 9090, 9091 and 9092.

7 Responses so far.

  1. rishav says:

    Used it, it’s great… thx for the post !

  2. Gaurav says:

    Hey Sur,
    I am running thin right now on my machine and it seems very fast.
    Thanks for sharing.

  3. rishav says:

    In windows, gem install eventmachine and gem install thin fails as it tries to build the gem.

    To install in windows you need to search for win32 binaries in rubyforge and these are the working versions (as of now):

    eventmachine-win32-0.8.1.gem
    thin-0-1.8.0-i386-mswin32.gem

    Thanks.

  4. sur says:

    hey guys,
    glad to know the post helped you. :)

    thanks for the information on windows, rd!

    Thanks.

  5. Arjun says:

    Hi Sur…thanks for the post…helped….I did not face any problem installing the thin and event machine gem in windows…
    But am having some issue running the thin server on my machine in cluster mode:
    >thin start -p 9000 -d -e production -s 3
    This gives me an error saying “amigious” option “-s”. It runs if i dont use that option.
    Can you tell me where I am going wrong.
    -Thanks
    Arjun

  6. Sur says:

    Hi Arjun,

    You pointed it out well.
    Being a linux user, I didn’t tried it on Windows. Out of curiosity I tried it on my desktop PC and found that cluster options are not even coming in thin –help though its working fine on my ubuntu notebook.

    No idea as of now… Would need to figure out if we are missing something on windows which might already be available on linux thats not being noticed explicitly.

    Thanks.

  7. Arjun says:

    Thanks Sur for the update. Will do some research on my side and will let you know if something comes up. One thing I found was Thin runs a general rails app much faster. But if you keep the server running without any restart in between say for 4 hours continuously in non-production mode, It tends to hand the notebook. Because as soon as I killed the server shell process in my task manager, the comp was back up in Windows. This might be my machine specific. Or it might be general. DId you or anyone face this issue?
    ciao,
    Arjun


Sponsors