Serving Python Web Apps

Newcomers to the world of Python are faced with a bewildering array of options for developing and serving their web apps. Python’s official documentation does little to cut through the clutter.

Enter Graham Dumpleton. I’ve never met him, but he appears to be the Python community’s unsung web hosting ninja. I highly recommend reading his recent Hosting Python Web Apps slide deck — it cuts through all the clutter. (You can find video of the talk on Youtube, too.)

The bottom line:

  • There are approximately a million different Python web frameworks. All of them speak WSGI. Choose one. For today, at least, use WSGI rather than FASTCGI/uWSGI/what not.

  • The most common architecture for serving python web apps is Apache + mod_wsgi running in Daemon Mode. Apache should be used to serve static content.

  • The second most common architecutre is nginx + gunicorn + supervisor. Nginx should serve static content.

I’ll go further and say that, while it’s fun to explore the vast world of web frameworks, it’s probably not necessary. Start with Django 1.4 and if it really doesn’t work for you, look further afield. Also: Apache is a rock-solid option — gunicorn feels like the flavor du jour to me. Properly configured, Apache runs very nicely even on memory-starved VPS instances.