How do YOU deploy your WSGI application? (and why it is the best way)

Ali Afshar picture Ali Afshar · Feb 22, 2009 · Viewed 14.1k times · Source

Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.

So how can it be done?

  1. Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
  2. Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
  3. as 2 but with reverse proxy from nginx, apache2 etc, with good static file handling
  4. Conversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server.

More?

I want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.

Answer

MrTopf picture MrTopf · Feb 22, 2009

As always: It depends ;-)

When I don't need any apache features I am going with a pure python webserver like paste etc. Which one exactly depends on your application I guess and can be decided by doing some benchmarks. I always wanted to do some but never came to it. I guess Spawning might have some advantages in using non blocking IO out of the box but I had sometimes problems with it because of the patching it's doing.

You are always free to put a varnish in front as well of course.

If an Apache is required I am usually going with solution 3 so that I can keep processes separate. You can also more easily move processes to other servers etc. I simply like to keep things separate.

For static files I am using right now a separate server for a project which just serves static images/css/js. I am using lighttpd as webserver which has great performance (in this case I don't have a varnish in front anymore).

Another useful tool is supervisord for controlling and monitoring these services.

I am additionally using buildout for managing my deployments and development sandboxes (together with virtualenv).