Cleanest & Fastest server setup for Django [closed] Cleanest & Fastest server setup for Django [closed] python python

Cleanest & Fastest server setup for Django [closed]


Since I was looking for some more in-depth answers, I decided to research the issue myself in depth. Please let me know if I've misunderstood anything.

Some general recommendation are to use a separate webserver for handling media. By separate, I mean a webserver which is not running Django. This server can be for instance:

  • Lighttpd (Lighty)
  • Nginx (EngineX)
  • Or some other light-weight server

Then, for Django, you can go down different paths. You can either:

  • Serve Django via Apache and:

    • mod_python

      This is the stable and recommended/well documented way. Cons: uses a lot of memory.

    • mod_wsgi

      From what I understand, mod_wsgi is a newer alternative. It appears to be faster and easier on resources.

    • mod_fastcgi

      When using FastCGI you are delegating the serving of Django to another process. Since mod_python includes a python interpreter in every request it uses a lot of memory. This is a way to bypass that problem. Also there is some security concerns.

      What you do is that you start your Django FastCGI server in a separate process and then configures apache via rewrites to call this process when needed.

Or you can:

  • Serve Django without using Apache but with another server that supports FastCGI natively:

    (The documentation mentions that you can do this if you don't have any Apache specific needs. I guess the reason must be to save memory.)

    • Lighttpd

    This is the server that runs Youtube. It seems fast and easy to use, however i've seen reports on memoryleaks.

    • nginx

    I've seen benchmarks claiming that this server is even faster than lighttpd. It's mostly documented in Russian though.

Another thing, due to limitations in Python your server should be running in forked mode, not threaded.

So this is my current research, but I want more opinions and experiences.


I'm using Cherokee.

According to their benchmarks (grain of salt with them), it handles load better than both Lighttpd and nginx... But that's not why I use it.

I use it because if you type cherokee-admin, it starts a new server that you can log into (with a one-time password) and configure the whole server through a beautifully-done webmin. That's a killer feature. It has already saved me a lot of time. And it's saving my server a lot of resources!

As for django, I'm running it as a threaded SCGI process. Works well. Cherokee can keep it running too. Again, very nice feature.

The current Ubuntu repo version is very old so I'd advise you use their PPA. Good luck.


As @Barry said, the documentation uses mod_python. I haven't used Ubuntu as a server, but had a good experience with mod_wsgi on Solaris. You can find documentation for mod_wsgi and Django on the mod_wsgi site.

A quick review of your requirements:

  • Easy to setup I've found apache 2.2 fairly easy to build and install.
  • Fast and easy on resources I would say that this depends on your usage and traffic. * You may not want to server all files using Apache and use LightTPD (lighty) to server static files.
  • Can serve media files I assume you mean images, flash files? Apache can do this.
  • Multiple sites on same server Virtual server hosting on Apache.
  • Rather not install other extensions Comment out anything you don't want in the Apache config.