Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a django site which is ajax intensive currently running on apache mod_wsgi with nginx as a reverse proxy.

Now is it better to retain my current setup or is it better to run my django site on tornado with nginx as a reverse proxy and load balancer?

The reason I'm asking is that I've read somewhere something like mod_wsgi wasn't designed for async stuff. I'm not really sure about that part though but It got me thinking that maybe tornado with nginx will be good for my setup since its non-blocking.

I need your advice. Thanks.

share|improve this question
up vote 3 down vote accepted

Django sits on top of the WSGI interface and that interface is by definition blocking. That you are therefore not using any async mechanisms in your web application, what benefits you get from using an async web server is greatly reduced. Any benefits are going to be more to do with the alternate server being lightweight and not carrying so much overhead and nothing to do with fact that async is used. To get the most from an async server you would need to ditch Django and write to the async APIs of the specific async server you are using.

It should also be highlighted that the initial benchmarks that were released about Tornado in comparison to Django on top of Apache/mod_wsgi were flawed. They claimed that Tornado was 4 times faster. That may have been true for a simple async web application written to Tornado APIs, compared to a Django hello world application, but if you compare it instead to a basic WSGI hello world program, performance isn't that much difference. Thus, performance of Django running on top of Tornado with a WSGI adapter isn't that much different to Django on top of Apache/mod_wsgi and when I tested them on MacOS X, Tornado was actually slower by a little bit.

If you still feel that going with a more lightweight server will bring you some benefits or may be easier to manage, I would suggest gunicorn instead of Tornado.

share|improve this answer
Wow that actually cleared what's been bothering me. Its the first time I've heard about Gnunicorn but it looks simple enough. Thanks for clearing things out. – Marconi Feb 12 '11 at 5:55
Note that an async web server still matters for serving static content. But this applies to most web severs these days -- nginx and lighttpd are fully asynchronous internally and even Apache 2.4 has an asynchronous mode (event MPM). – intgr Jul 2 '12 at 14:20

We use nginx as load balancer and uWSGI as fast WSGI server. So far no problems

share|improve this answer
Thanks for the info. I have tried nginx + fastcgi and it works great too but I'm more interested on how will my django site perform on nginx + tornado. – Marconi Feb 10 '11 at 16:52
Django and RDBMS are sync. Tornado isn't the best choice. – alvosu Feb 10 '11 at 16:59

A great solution to serve Django (or other WSGI apps) actually is Nginx + Gunicorn. So far, this setup works very well, and the Gunicorn software is a recent one with a very good reception by the Python and Django community. You should try it.

I'm currently using supervisord to handle my gunicorn processes but other solutions are possible.

share|improve this answer
Thanks for the links, I'll definitely try it. – Marconi Feb 12 '11 at 5:53
Another recommendation for supervisord. Works well for demonising celery as well. – ostrokach Aug 7 '15 at 15:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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