I'm busy configuring an nginx reverse proxy that resides on one server, which will sit in front of one (for now) apache webserver on a different server, which will be serving a Django appplication via mod_wsgi.

While perusing the Internet a few days ago, I saw some nginx configuration example where the guy had the same server set up with multiple ports in the upstream directive.

So, rather than doing this (what I have right now, more or less)

upstream webserver {
    server backend1.com;

He had:

upstream webserver {
    server backend1.com:8000;
    server backend1.com:8001;
    server backend1.com:8002;

And obviously with Apache configured to listen on those three ports. (I think in the example I saw, which I can no longer find, it was a mongrel backend running Rails, for whatever that's worth.)

Anyhow, my question is, what kind of advantages or disadvantages are there with this approach? I know either way works and I can easily configure either option, but I was just wondering if anyone could shed some light on whether this is a good/bad/unnecessary configuration and why.

Many thanks for any wisdom offered.


The reason for the multiple back ends is that Mongrel is a single process. In order to scale you would need multiple processes, one or two per core, and let the proxy provide a single entry point. Additionally your proxy is likely to be multithreaded and able to manage user connection while keeping the single process servers busy.

If your back end is Apache, it'll spawn multiple child processes to handle incoming requests assuming your not running the mpm-worker so there is no need for multiple processes.

  • Even with worker MPM it will spawn multiple process as necessary up to the limit configured. If using mod_wsgi you preferably would use its daemon mode. If for some reason you really wanted to use embedded mode, then worker MPM is preferred over the usual default of prefork. – Graham Dumpleton Mar 26 '11 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.