On Tue, 5 Sep 2000, Michael Peppler wrote:

> Stas Bekman writes:
>  > On Tue, 5 Sep 2000, Michael Peppler wrote:
>  > 
>  > > The idea is to create a pool of connections during the main
>  > > apache/modperl startup. Because these connections end up in the code
>  > > segment for the child processes they are completely shareable. You
>  > > populate a hash in a BEGIN block with x connections, and then provide
>  > > some calls to grab the first available one (I use IPC::Semaphore to
>  > > coordinate access to each connection).
>  > 
>  > There is no such a thing as a code segment in Perl. Everything is handled
>  > as data, so unless you write your code in C and glue it to Perl, you
>  > cannot ensure that some read/write variable wouldn't land on the same page
>  > with the data that stores the connections.
> 
> I guess it's in the shared data segment then. In any case the
> connections and the datastructures that go with them are visible from
> all the child httpd processes.

The shared segments are shared until the moment, when one of the data
structures is being written to, which makes the page (1k to 4k) dirty and
unshared. See the http://perl.apache.org/guide/performance.html (the
shared memory sections) for a more detailed explanation of the memory
management under Perl.

>  > > The advantage of this solution is that connections don't go down when
>  > > the apache child dies (for example because the MAX_REQUEST per child
>  > > has been reached).
>  > 
>  > If there would be a way for a chile to know its processor slot as seen by
>  > Apache::Status, there will be no need for any semaphoring technique --
>  > each process will access the connection by asking for its slot
>  > number. This will work because when the child being reaped off a new
>  > process replacing it is running in the same slot. Looks a much faster way
>  > to me if you get hold of the slot number.
> 
> I'll look into that - thanks.

You are very welcome. It'd be cool to have yet another neat technique to
squeeze more from mod_perl :)

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://jazzvalley.com
http://singlesheaven.com http://perlmonth.com   perl.org   apache.org


Reply via email to