Which one of these is a better option to use alongside "latest rails" application? Mongrel, Thin, WEBrick and Passenger
Asked Answered
A

3

8

I have been playing around and evaluating other options to rails' default WEBrick server and Thin was the most painless and clean thing which worked very well!!

which one of these Mongrel, Thin, WEBrick and Passenger would you recommend and why..? are there any scalability perks(cluster friendly or configs which can handle some sort of scale) which come with any of these servers.. or should scalability even be a parameter while evaluating them?

Agbogla answered 27/10, 2012 at 5:24 Comment(0)
C
9

Dipak already answered half of your question but let me clarify on things a little bit. (I am one of the Phusion Passenger authors.)

  • WEBrick is a toy web server. Nobody uses it in anything but development because it performs poorly and is said to leak memory.
  • You said Thin worked well. Have you already set it up in a reverse proxy configuration? Because that's what people do in production scenarios. It is not safe to expose Thin (or Mongrel, or Unicorn) directly to the Internet.
  • You may be interested in reading Ruby on Rails server options and the Phusion Passenger architectural overview for more etailed explanations.

When it comes to scalability, there's not much difference. They all perform very similar in production, they all scale in about the same way, and any problems you encounter will most likely to be caused by your app or by Rails. Well, except for WEBrick, which you really shouldn't use in production. You may see difference in hello world benchmarks, but that will be all. In production use most of the time will be spent in the app so any minor speed differences visible in hello world benchmarks will become completely invisible.

There are some subtleties to be aware of though.

  • Phusion Passenger provides a feature called global queuing. It solves a specific problem, explained in detail in the manual. By default Nginx and Apache proxies requests in a round-robin manner so they suffer from this problem, while Phusion Passenger does not. There are ways to get around this when not using Phusion Passenger but they require specific configuration or the installation of additional web server modules.
  • The I/O model may or may not be important depending on the nature of your application. Mongrel, Thin, Unicorn, they are all multi-process single-threaded. This works great for traditional web apps which looks up stuff in the local database and renders something, but sucks majorly for apps which perform a lot of HTTP API calls or otherwise have to wait a lot on I/O. Why Rails 4 Live Streaming is a Big Deal explains this in detail.

    Phusion Passenger is also multi-process single-threaded, but Phusion Passenger Enterprise supports multithreading. Phusion Passenger Enterprise is a commercial variant of the open source Phusion Passenger, with a variety of features useful for large-scale production environments.

  • In large production environments, some features become important, e.g. rolling restarts, not showing anything wrong when a deployment failed, etc. Mongrel, Thin, Unicorn, Phusion Passenger, they all expose these features to some degree, but some require more admin effort than others. For example to implement rolling restarts in Mongrel and Thin, you need quite a lot of steps in your deployment scripts. Unicorn doesn't require as many steps, but still significantly. This is where Phusion Passenger Enterprise shines: it takes all these features and turn them into a single config option. Turn the option on and the software takes care of the rest.

So, pick whatever option you think is best for your scenario.

Carbon answered 31/10, 2012 at 8:41 Comment(3)
was away for quite some time.. thanks for the great reply.. i have started using passenger+nginx as of now.. the requirements are not that extra-ordinary and hence scalability hasn't been such an issue!! thanks again!!Agbogla
@Carbon I have a Rails application which makes extensive use of the Faye ruby gem, which in turn makes extensive use of websockets and comet (long HTTP polling). In other words, I have hundreds of TCP connections that remain open for long periods of time. Various parts of the site use real-time data. Initially I was using Apache2 but am deciding to migrate to nginx because of its asynchronous i/o multi-threaded strength. Will Passenger play nice more so than Thin as an application server?Kobarid
@Kobarid If you're using WebSockets then Passenger Enterprise (for multithreading) with Nginx will work out very well, just like Thin. Passenger Enterprise's main advantage over Thin is in better tooling and better documentation. Also, please checkout the WebSocket tuning instructions.Carbon
K
1

The easiest to set up for production will probably be Apache and mod_rails (passenger). If you want to be using the new hotness, you could give nginx and passenger a whirl.

For development mongrel is usually the easiest to work with. Most Windows IDE's (RadRails, Netbeans) give you the choice to use Webrick or Mongrel for development work and let you control the servers from the IDE itself.

Update

Four Choices

There are really four choices, well, plus WEBrick, but that would be an unusual choice for a production server. Approximately in order of increasing complexity...

nginx + Mongrel nginx + Passenger Apache + Mongrel Apache + Passenger (There is Phusion Passenger Standalone, but that's really an nginx + passenger compiled together, so I'm not counting it, although it may be a good option for some people.)

A larger site may then add specialized layer 7 hardware (NetScaler, F5, ...) in front of the servers.

Karolinekaroly answered 27/10, 2012 at 5:28 Comment(2)
thanks for the reply.. this is more for non development purposes.. i think i'll give nginx one a try.. any insight on the second question..?Agbogla
I disagree with your sorting on the order of complexity. Phusion Passenger + Apache and Phusion Passenger + Nginx are about the same complexity, usability-wise. But both are less complex usability-wise than Apache/Nginx + Mongrel. Phusion Passenger Standalone should be the easiest of them all because it's just a single command, there's no need to compile Nginx yourself, and the result can be immediately exposed to the Internet. Also, Phusion Passenger + Nginx is not "the new hotness" - it has been around since 2009.Carbon
H
0

Thin is as easy as gem 'thin' for development and production

Hog answered 29/10, 2012 at 4:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.