New Django/Python deployment stack: Django, Cherokee, and uWSGI.

What I had:

In the past couple of months I have been looking for alternatives to my current web stack. My current web stack is:

Django (my favorite web framework),

nginx (frontend web server),

apache + mod_wsgi (to serve the Django application), and

PostgreSQL the database, obviously.

Django isn’t getting replaced because I like it and I can’t get my coding partner to switch to anything else no matter how magical or revolutionary.

I fucking hate nginx configuration files so that was going out the window as soon as I could find a suitable replacement. Apache + mod_wsgi I’m not entirely unhappy with but the extra memory usage from Apache bloatware and, again, the ugly configuration files are annoying, especially, with non-standard PYTHONPATHs. Yes, I know I can do sys.path magic to work around it but I shouldn’t have to, this is 2010 not 1990, fuck that.

PostgreSQL is a great database server and I’m happy that the Django ORM just works with it so I don’t have to build my own ORM, big plus. I would love to give CouchDB a chance but I don’t have the time to rewrite _everything_ to work with it, I’ll use it with something else.

What I Found:

Looking for other web servers I came across Cherokee (﻿http://www.cherokee-project.com/). The documentation on the Cherokee site is phenomenal, when have you EVER seen screen casts for how to configure your web server? Oh, and what is that? A screencast about deploying Django using uWSGI or Flup? Why, yes, that what you are seeing, isn’t that great? That isn’t the only good thing, Cherokee stacks up, speed wise, with nginx, has plenty of configuration “wizards”, and has a web front end for configuring the web server. I was mostly sold just from the documentation, compare this with this. The Apache docs may be informational but they are completely worthless if I want to get something done, today.

Configuring Cherokee is like using the WebFaction hosting interface, easy to use and as powerful as you want it to be. In fact, in the next blog post about how to set everything up you can see the similarities. (Disclaimer: I work for WebFaction so I am a little biased, however, in the 10 years that I have been dealing with web hosts I have never seen another hosting company build something so great at what it does: allow you to do as much or as little as you need, to get things done.)

After hours of looking through the different ways to serve WSGI applications I finally settled on uWSGI, mostly because it is written completely in C and has a really easy install process (read: one command, make). uWSGI is also able to used with Cherokee and Django really easily, see the screencast here: ﻿http://www.cherokee-project.com/screencasts.html#django_uwsgi. Now that is what I was looking for, easy to configure, easy to use, powerful, and fast. Also, setting the PYTHONPATH is as simple as 1 or more XML tags, like so:

<pythonpath>/path/you/are/adding/</pythonpath>

Fantastic! Have another path you want used? Add another line, that’s it.

Processes are automatically managed and restarted when they are killed. uWSGI has amusing errors, such as:

﻿…brutally killing workers…

DAMN ! process 14955 died trying respawn …

Log files are much more fun to read when they include some humor even if shit is wildly broken.

Next post will be about how to set all of this up, from nothing to a working deployment of a working Django app using Cherokee and uWSGI.