Current Rails Stack

My current Rails webserver stack is Nginx + Apache + Passenger

Why use nginx?

Keep Alive & Long Polling

Apache in it's default setup has a high chance of falling over when there is high traffic. This is because of the "Keep Alive" setting. (More details) Since nginx doesn't spawn a process per client, turning on "Keep Alive" does not affect nginx performance. It is desirable to enable Keep Alive because it decreases page load time.

Also if you want to use long polling you cannot use Apache without hitting serious bottlenecks due to its 1 thread/process per connection nature.

Varnish alternative

Nginx can be used to cache responses from the backend. Varnish is the probably the best tool for this but it can be an overkill.

Why use Apache?


Unlike nginx which needs modules compiled in when it is built, you can easily add modules to apache. Passenger is hence much easier to setup with apache than with nginx.

OS updates

Apache is fairly stable and hence the best way to install it and manage it through your OS provided packages. Updating is painless. Your modules should work after an Apache update. Nginx on the other hand is fast moving and if you want the latest and the greatest, you have to compile it from source. If you are using custom modules you have to compile it in. Updating nginx means compiling from source again and you have to remember to include your custom modules. So it makes sense to depend upon only the core nginx modules.

blog comments powered by Disqus