Nginx + Django: mod_wsgi vs FastCGI

3 min read · nginx, django, wsgi, fastcgi, performance

(Translation of my previous post).

Yesterday I have finally sorted out my trouble with compilation of nginx' mod_wsgi and got it working (how much means slash in our life ;-).

Configuration to get Django application running is quite simple - django.wsgi, which is used for Apache’s mod_wsgi, fits perfectly. I’ll not describe all configuration, because code is unstable and needs testing and is’s contra-indicated to run it on production now.

Lets do the fun - testing. :-) Simple page, 15 queries (PostgreSQL on same pc), 2 workers for nginx (I have tried 3 and 4 - they both are slighty slower, for 2-4 ms). Two variants of testing queries (ab -n 1000 -c 20 and ab -n 10000 -c 500) and three variants of servers (mod_wsgi, prefork fastcgi, threaded fastcgi). Hardware (this is not so interesting, because performance is interesting only in comparison, but why not to show it?)

First - ab -n 1000 -c 20 (around of 10-12 runs for every variant):

I.e. in most cases for such load FastCGI is slighty faster (and uses somewhat bigger amount of resources). But… lets go further? ;)

Second - ab -n 10000 -c 500 (here I got 3-4 runs for every variant):

What I can say here? Lets wait for stable mod_wsgi release! :-) Thanks, Manlio, for creating it. :-)

  1. xmobar - small statusbar, written in Haskell. Displays system state and other various information ↩︎

If you like what you read — subscribe to my Twitter, I always post links to new posts there. Or, in case you're an old school person longing for an ancient technology, put a link to my RSS feed in your feed reader (it's actually Atom feed, but who cares).

Other recent posts

ngrok for the wicked
PostgreSQL collation
History snapshotting in TwinSpark.js
Code streaming: hundred ounces of nuances
Useful shell prompt