On Wed, 2005-03-16 at 00:26 +0100, André Warnier wrote:
> I have previously gone though a lot of perl and mod_perl documentation, 
> and perl module descriptions, and I never seemed to find a clear answer 
> about wether yes or no it was possible to share in-memory data between 2 
> perl processes (or threads) running under Apache.

In theory you can share variables between perl threads.  However, perl
threads are incompatible with many popular CPAN modules at this time,
and have performance penalties compared to forking, so we don't
recommend using them for people who have a choice, i.e. people not on
Win32.

> What I am wondering about is this : such a possibility of sharing a 
> memory area seems like something rather desirable under some 
> circumstances.

The thing is, the solutions already mentioned in this thread are very
fast.  For example, BerkeleyDB is an in-process call to a library that
keeps a shared memory cache.  In other words, using BDB means using
shared memory.

> On the other hand, mod_perl seems to have some deep interactions with 
> the innards of the Apache server, for example direct manipulation of the 
> "bucket brigades".  How come no-one has come up yet with some scheme to 
> "hijack" one of these bucket brigades (or some other internal Apache 
> memory area) to provide such a capability ?

I think at least some of that is exposed in the APR:: stuff in mp2.
I've never tried messing with it, because these other solutions are
fast, reliable, and easy.

> Also, for instance, the DBI module and it's companion Apache::DBI 
> provide persistent connections to databases. And to my knowledge, they 
> are available under Unix as well as Windows.  For doing this, there must 
> be some form of memory sharing at work, isn't it so ?

No, there is no sharing at all with Apache::DBI.  It keeps a separate
database handle in each process and reuses it for future requests in
that same process.  There is no "pool" of connections.

Whether or not Apache::DBI will work under threads is not very certain
at this point.  It depends on the thread-safety of your DBD:: module.

- Perrin

Reply via email to