18

Which of Lighttpd and Nginx is, basing on your experience, better suited for Django? I've used both and can hardly notice any difference at all, they just work fine... Are there any use cases when one of them acts much better than the other? When answering please take in account both simplicity of configuration and efficiency.

My usual setup is to have a separate Django FCGI process (like in ./manage.py runfcgi daemonize=false port=8098 host=127.0.0.1) launched via daemontools or an init.d script and lighty/nginx acting as a reverse proxy.

Oh, and if you feel some other http server is much better for Django than Lighty and Nginx, please don't hesitate to share your thoughts.

1
  • If a fastcgi service dies, daemontools supervise will restart it within five seconds, so the service is back up. But you still have a tiny lag of downtime there. In my deployment I found fastcgi to be fragile stopping unexpectedly under mild pressure. After a few downtimes and couple awkward phone calls from clients, I switched Nginx to reverse proxy to Apache mod_wsgi and everything is just humming ever since.
    – user64550
    Dec 23, 2010 at 16:07

4 Answers 4

14

Both Nginx and Lighttpd are better choices than apache when it comes to using them as a reverse proxy for Django, Rails, etc. Both support FastCGI and Http proxying. Both offer a single threaded select() (or better) based model for efficient resource usage.

However my vote goes to Nginx, it's got a very active user base (it's currently the darling of the Ruby on Rails set), and is under active development. Lighttpd could be mistaken for being dead, 2+ years and we're still waiting on a beta of 1.5.

7

mod_wsgi is recommended way to get Django application into production. Apache's mod_wsgi is much better than nginx. You can't find official package (in current Linux distributions) for nginx's mod_wsgi and You need to compile it by yourself. I like nginx but if You want to play safe, play with Apache mod_wsgi.

1
  • 2
    Nginx mod_wsgi is not something you'd want to use. Nginx is best to serve static content and reverse proxy to Apache mod_wsgi to generate the dynamic. You wouldn't want to use asynchronous web server for both generating dynamic pages and serving static content. Apache mod_wsgi on it's own does not make much sense either. You woun't want that beast to be busy spraying around static files, while it is supposed to do the heavy lifting. Read more here b-list.org/weblog/2008/jun/23/media
    – user64550
    Dec 23, 2010 at 15:57
5

mod-wsgi is the best way to run django apps in production, less fiddly than fastcgi and no issues with start up times etc.

The real mod-wsgi is for apache, but there is another mod-wsgi for nginx. The apache one is brilliant, I can't comment on the nginx one.

Personally, I'd stay away from lighttpd. It doesn't have the stability of nginx, I've not yet seen a case of lighttpd that doesn't have a memory leak.

Basically, my first choice would be apache 2.2, my second choice would be nginx.

Don't believe the hype about response time and scalability. Truth is, it just doesn't matter. (Google use Apache).

4
  • Google use GWS (en.wikipedia.org/wiki/Google_Web_Server) not Apache. Yahoo use Apache, but it's an ancient fork of 1.3. May 27, 2009 at 13:18
  • YouTube uses or at least used lighttpd, so I don't think that it's so bad. See highscalability.com/youtube-architecture. May 27, 2009 at 15:33
  • Yes, but while GWS is a secret project, it is known it be based on Apache.
    – Rich
    May 30, 2009 at 2:20
  • what YT is not saying is that they have their own fork of lighty. Is true lighty has a well known memory leak problem. I believe they may have fixed it by now, but the rep persists. Jan 25, 2012 at 16:56
2

Also, consider using Google App Engine. You can host your Django project there for free and not have to worry about maintaining the server infrastructure.

2
  • 8
    Django on GAE has significant limitations, like not supporting any of Django's datbase/ORM features. If it supports what you need, great - but check carefully!
    – Kevin
    May 27, 2009 at 13:33
  • I believe MySQL is now supported by GAE so I presume ORM will be as well. Though is true I has no experience trying it out. Django without ORM is like porn without torrents. Jan 25, 2012 at 16:54

Not the answer you're looking for? Browse other questions tagged .