Don't use mod_python
wiki.python.org
wiki.python.org
The Apache request-handling chain is much richer than simply passing off incoming requests to a CGI or PHP script. Using mod_{perl,python,ruby,etc.}, you can implement authenticators, URL-rewriting modules, log handlers, output filters, etc., and take advantage of the mature Apache infrastructure for such code.
Basically, if you want to be able to slice and dice HTTP requests at every stage of processing, not just the content-generation one, the Apache mod_* add-ons are a pretty powerful tool for doing just that.
Case in point: I'm currently working on an application that uses mod_auth_kerb to perform Kerberos password authentication on behalf of users, then fork a background server which has access to that user's Kerberos credentials, and proxy future connections from that user to the dedicated backend.
Doing that using mod_rewrite requires using the RewriteMap 'prg:' map type, which introduces a single choke-point in the application: namely, the single script responsible for spawning the backend servers. That script also runs in the one Apache master listener, which means that no other incoming requests will be answered until the rewrite script returns its output.
If I were instead using mod_perl (as I suspect I will be, before this moves into production) I would be able to have each Apache child process handle its own forking of backends for requests it was handling.
1. You can get total control over the request.
2. Mod_python provides a set of wrappers to mimic standart python CGI objects what greatly simplifies your life
3. Basic load tests say that mod_python is robust and fast
4. Installation is easy
The only thing that I've found confusing is unicode support (take a look at http://www.modpython.org/pipermail/mod_python/2004-June/0158...)
The only thing that I need to know about mod_python - is the list of successful commercial deployments.
What about the cons, I would also like to know who are these guys from this PoundPythonWeb, they look like someone official, but I'm always feel suspicious when someone says: "Don't use this" (except the case when the person is the author :))
1. That's what package managers are for.
2. If you're in the position of configuring your own web server then this probably doesn't matter to you.
3. See #1.
4. True, but your /usr/bin/python processes will be lighter because they won't exist.
5. I have no idea if this is true, but no evidence is provided.
6. My personal experience with mod_proxy has been...unhappy.
7. ???
8. See #5.
Edit: I switched to using fcgi and it's wayyyy faster. So there's reason #9.
The difference is in where they hook into the request-handling workflow within Apache. Both FastCGI and WSGI apps only receive the request after Apache (or lighttpd, nginx, et. al.) have finished doing access control checks, URL rewriting, header parsing, etc.
Code inside the mod_python interpreter, on the other hand, can hook in to any of those earlier stages of request processing, which allows it to do things like block a request, alter the Apache log format, or look up a vhost docroot in a database, all before any content is generated.
The downside is that each and every Apache process on your server has a full copy of the Python interpreter embedded inside, which can cost you a pretty serious chunk of RAM when you start dealing with servers running 25-50 (or more) httpd processes.
What are the preferred ways to deploy wsgi apps?