Python as a Server vs Running Under Apache

Mike Meyer mwm at mired.org
Sun Jan 1 19:46:20 EST 2006


"mojosam" <zjw1hu702 at sneakemail.com> writes:
> Is this advice accurate?  Are there other things to consider?  Isn't
> there just some way (short of running something like Zope) that would
> keep Python resident in the server's RAM?  This is a shared server, so
> the web host probably doesn't like stuff sitting around in RAM.

Jean-Paul Calderone has already answered most of these, so I'll get
the last one.

Stuff "sitting around in RAM" unusued on a busy server leaves RAM
pretty quickly on a modern system. The executable pages will just be
tossed, and reloaded from the executable file when they are needed
again. Data pages will be written out to disk in the swap area, and
read back in when they are needed. Unless your program's behavior is
very strange, this will generally be quicker than recreating the
program state from scratch. The end result is that your program loads
faster, and the real RAM used to support this is negligible.

> Right now, I only need small programs to run.  E.g., I'm thinking of
> embedding a Live Journal blog in my web page.  Live Journal gives you
> several ways of doing this, one of which is three lines of Python code.

Trying to make your dynamic HTML content "fast" before you need to is
a premature optimization. Yes, CGI is slow compared to some of the
alternatives. But forks on Unix are still cheap, and you can handle
quite a bit of traffic with it on a modern system before you run into
a wall. Do it with CGI first, and fix it later if you need to.

      <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list