Re: Database Connections

Sebastien Bigaret <[email protected]> 06 Aug 2004 21:33:42 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
Duncan McGreggor <[email protected]> wrote:
[snipped]
> We've been running a default mod_python apache configuration: 1 main process,
> and multiple child processes are spawned as needed. I don't and have never
> programmed in threads and don't really understand it, so you'll have to
> forgive my terminology, if incorrect...
> 
> I guess we could setup mod_python to run a single interpreter
> (http://www.modpython.org/live/current/doc-html/dir-other-pi.html), I would
> want to do that only if we had to though... I think we would loose many of the
> performance gains our client sought by going with mod_python in the first
> place...
> 

I do not think so, because requests can be handled concurrently within a
single interpreter. And that's what I believe it is done --quoted from
http://www.modpython.org/live/current/doc-html/pyapi-interps.html:

    Default behaviour is to name interpreters using the Apache virtual
    server name (ServerName directive). This means that all scripts in
    the same virtual server execute in the same subinterpreter, but
    scripts in different virtual servers execute in different
    subinterpreters with completely separate namespaces

I've not played a lot with mod_python (just a few hours, in fact), but
AFAIK this means that a given application will always be served by the
same interpreter.  And in such a configuration:

  - the ECSessioning works,
  - so each session will get its own EC,
  - you'll basically get one connection to the database for all.

Now, this can be fine... or not, depending on the type of application
you're currently building (I mean, its characteristics, esp. if you can
expect heavy load).

For example, say that some of fetches can take some time --can you wait
for a fetch to be finished before serving others?  If your app. does not
fetch a lot, maybe it's not a pb, but if most of its requests end up
with one or more ec.fetch() then the default behaviour will probably not
be suitable.

And again, could you be more explicit whether in your first mail you
meant that "for each session's EC there exists one and only one
connection to the db"??

-- Sébastien.



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com