|
francois lepoutre
francoislepoutre at compuserve.com
Tue May 13 18:13:40 EST 2003
Hi
> I'm trying to plan the most efficient way to implement an apache
> project. And I have a really basic question about how mod_python (or
> any apache 'mod 'kind of framework, probably) works. I think i've read
> that a major advantage of mod_python is the fact you dont have to
> re'load the interpreter for each instance... but i'm wondering if this
> also equates to having a global, accessible, code space that python is
> operating in....
Nearly so. Depending on your platform.
on win32:
You will one workspace on win32 with shared code space
(beware of that apache/win32 is threaded you will have to
organize some locking when updating the python data structures)
on linux:
not one python interpreter but a series of them depending on the
context (apache setup and stress level)
> I'm following the examples in the documentation, and am using the
> 'handler' example, and have a python script with functions defined that
> do the work (there is a database connection happening with an Interbase
> server).
>
> What I"m trying to do is to have a dictionary created and available to
> all users - without having to re'create the dictionary for each apache
> visitor. I have a reason to NOT want to accomplish this using a
> database table - even though the dictionary is quite large, and requires
> a lot of overhead each time it's created.
Sure, you can build your code in such way that your apache mod_python
handler downloads what is necessary at loadtime and keep that stuff
(dictionnaries and the db handler ) buffered within the python "memory
space".
Only once in a while the python interperter be restarted (depending on
apache
setup), your memory workspace will be recreated from the db
(possibly a couple of seconds).
Perf will be excellent in this situation. At later calls to your stuff
apache
will be "python-driven". That's what we do.
We rely heavily on highly secure but time-consuming db-based datastructure.
The possibily to smartly buffer your db stuff within python was our reason
to
switch into python/mod_python (from iis/isapi).
Welcome onboard :)
François
PS
If you wish to organize session-handling this way, it is doable as well but
it
will be a bit more complex as you will need to resync your set of apache
instances (each one handling its own session pool).
|