Conrad Steenberg
conrad at hep.caltech.edu
Fri Nov 1 14:39:55 EST 2002
Hi Just my 2c: Using Berkeley DB works great for small things like counters and other small pieces of persistent data. It is already installed on most systems, so all you need is the Python binding from http://pybsddb.sourceforge.net/ You can open a connection to the DB and store it as a global variable in your mod_python script when the script is imported - i.e. not within the handler. You can use e.g. cookies to identify connections. HTH COnrad On Thu, 2002-10-31 at 23:20, Jørgen Frøjk Kjærsgaard wrote: > On Thu, 31 Oct 2002 17:04:30 -0500, Antonio L Rodriguez wrote > > Forgive me if this is more of an apache process question, but I > > couldn't find it covered clearly in the docs. > > > > When apache boots up (on *NIX) its starts a bunch of children > > processes. Does each child have its own separate image of mod_python > > execution space that is totally separate from the other images? > > Correct. Apache 1.3 starts a process per simultaneous request it can handle. > Apache 2.0 is capable of running in threaded mode where the threads share > memory and thus can have global shared variables. I have no experience with > 2.0 so far, though. See the documentation for Apache, in particular > http://httpd.apache.org/docs/mod/core.html#maxclients for 1.3 and > http://httpd.apache.org/docs-2.0/mod/mpm_common.html#maxclients for 2.0. > > > That is, if I define a global var to measure hit counts in a script > > and then I see this var dance up and down as each of the child > > processes handles the request, do I infer correctly that there are > > separate python interpreters living inside of each child process? > > Exactly. You never know which process the next request will hit. > > > If this is so, I'd be curious how people do global data structures > > in this model, i.e. a database connection pool. > > Truely global data with Apache 1.3 requires some kind of shared memory, which > isn't supported by mod_python. I use one database connection per child. This > works well, but of cause, if you configure your Apache to run with a lot of > idle children, you'll have a lot of idle connections. If your database system > has a limit as to how many simultaneous connections it can handle, be sure you > don't hit that limit. Raise it or limit the number of Apache processes. > > /jfk > > -- > Jørgen Frøjk Kjærsgaard > Metation ApS - the system integrators > Kystvejen 29 - DK 8000 Århus C - www.metation.com > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://www.modpython.org/mailman/listinfo/mod_python -- *-----------------------------------------* | Conrad Steenberg | | Caltech, Mail Code 356-48 | | Pasadena, CA, 91125 | | e-mail: conrad at hep.caltech.edu | | Tel: (626) 395-8758 | *-----------------------------------------*
|