Why use Mongrel2?
Asked Answered
L

2

77

I'm confused what purpose Mongrel2 serves/provides that nginx doesn't already do.

(Yes, I've read the manual but I must to be too much of a noob to understand how it's fundamentally different than nginx)

My current web application stack is:
- nginx: webserver
- Lua: programming language
- FastCGI + LuaJIT: to connect nginx to Lua
- Postgres: database

Lactose answered 22/5, 2011 at 16:0 Comment(1)
does the same, just different. pick the one you likeHent
P
116

If you could only name one thing then it would be that Mongrel2 is build around ZeroMQ which means that scaling your web server has never been easier.

If a request comes in, Mongrel2 receives it (nothing unusual here, same as for NginX and any other httpd). Next thing that happens is that Mongrel2 distributes the task of compiling a response to n (ZeroMQ-enabled) backends, waits for them to do the work, receives results, compiles the response and sends it off to the client.

Now, the magic is with the fact that n can be any number and, that each of n can be written in any language as supported by ZeroMQ (20 or so) plus, all goes across the network so each n can be a dedicated box, possibly in another datacenter.

In other words: with NginX and all the rest you have to do scalability in your logic tier, Mongrel2 allows you to start (from a request/response cycle point of view) this right where the request hits your infrastructure, at the httpd rather than letting complexity penetrate down to your logic tier which blows complexity upwards by at least one order of magnitude imo.

Pekingese answered 26/5, 2011 at 9:21 Comment(1)
@MarkusGattol What's the purpose of fastcgi? I can do that with it. In any language, no?Theis
T
13

You should look at the strengths of each and decide to use either or both depending on your use cases..

While, it seems that nginx does everything that mongrel2 provides in the surface, you'll find there are major differences in focus between the two.

Nginx shines as a front-end webserver, that can proxy requests to your backend webservers/appservers and also serve static content.

Mongrel2 is a slight change in the stack. As mentioned, it's power comes from it's use of zeromq as the transport layer between it and the backend appservers. It can serve dynamic request urls (app requests) and direct the compute portion of the task out to different backends using zeromq.. mongrel2 allows you to serve not just http, websockets etc, but other protocols (if you're inclined to do so) all from the same server. the user would never know that portions of the app are being served from different backends.

If your requirements for the functionality of your webapp keeps changing or you want to add things like streaming, the ability to code in different languages in the back end etc, then I would definitely look at mongrel2. Or even have a hybrid where you use nginx/haproxy/varnish for static files and caching, and everything else is directed to mongrel2.

Tacky answered 4/1, 2012 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.