Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 817
Ali Afshar Avatar asked Feb 22 '09 00:02

Ali Afshar


People also ask

How deploy WSGI with Django?

Configuring the settings moduleWhen the ASGI server loads your application, Django needs to import the settings module — that's where your entire application is defined. Django uses the DJANGO_SETTINGS_MODULE environment variable to locate the appropriate settings module.

What is WSGI application?

The Web Server Gateway Interface (WSGI, pronounced whiskey or WIZ-ghee) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. The current version of WSGI, version 1.0.


1 Answers

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).

like image 77
MrTopf Avatar answered Sep 28 '22 15:09

MrTopf