Re: shared memory

[prev] [thread] [next] [Date index for 2005/03/15]

From: Jonathan Vanasco
Subject: Re: shared memory
Date: 23:40 on 15 Mar 2005
He's my naive understanding of your concerns, someone here may have to=20=

correct me:

On Mar 15, 2005, at 6:26 PM, Andr=E9 Warnier wrote:
> I have previously gone though a lot of perl and mod_perl=20
> documentation, and perl module descriptions, and I never seemed to=20
> find a clear answer about wether yes or no it was possible to share=20
> in-memory data between 2 perl processes (or threads) running under=20
> Apache.
It's not.  Its part of the forking model and design.  That's why people=20=

suggested the use of DBs and caching systems such as memcached -- you=20
can store your data into a foreign object -- either a db or a memory=20
agent -- and then let separate processes or machines access it. =20
Anything you want to do can easily be handled by either a memory cache=20=

or a db cache.

>  How come no-one has come up yet with some scheme to "hijack" one of=20=

> these bucket brigades (or some other internal Apache memory area) to=20=

> provide such a capability ?
it sounds like you want to defeat the design of the forking model --=20
something like what you want would be more of a standalone daemon, and=20=

not Apache.

> Also, for instance, the DBI module and it's companion Apache::DBI=20
> provide persistent connections to databases. And to my knowledge, they=20=

> are available under Unix as well as Windows.  For doing this, there=20
> must be some form of memory sharing at work, isn't it so ?
If you instantiate a DBI handle before the fork, then that handle is=20
shared to all the children.  If you instantiate the handle after the=20
fork, the handle belongs to only that child , and shared across the=20
requests of that child.  So, if you get a handle, then spawn 12=20
children, they will each share the single handle.  If your code creates=20=

a handle after the fork, then you will have 12 handles.  There's a=20
section on 'shared memory' in both mod_perl books that explains it=20
better than my attempt -- there's also a section on using startup=20
scripts to preload all the info.

At first, the forking model is strange, its aggravating, and sometimes=20=

I wanted to kick it =96 it took a while for me to get used to it, and =
see=20
why it makes sense.  I still wish there were some ways to easier share=20=

data between children (maybe there are, and I no one on this list has=20
answered my hopes yet) -- but I've found using a db pretty damn good --=20=

and memcached supports sharing data between machines too.

(message missing)

shared memory
=?ISO-8859-1?Q?Andr=E9_Warnier?= 16:35 on 15 Mar 2005

Re: shared memory
Jonathan Vanasco 16:37 on 15 Mar 2005

Re: shared memory
=?ISO-8859-1?Q?Andr=E9_Warnier?= 17:07 on 15 Mar 2005

Re: shared memory
=?ISO-8859-1?Q?Andr=E9_Warnier?= 22:53 on 15 Mar 2005

Re: shared memory
Martin Moss 17:47 on 15 Mar 2005

Re: shared memory
Perrin Harkins 18:04 on 15 Mar 2005

Re: shared memory
Jonathan Vanasco 19:11 on 15 Mar 2005

Re: shared memory
Perrin Harkins 19:48 on 15 Mar 2005

Re: shared memory
Dan Sully 19:53 on 15 Mar 2005

Re: shared memory
jonathan vanasco 00:30 on 17 Mar 2005

Re: shared memory
Jonathan Vanasco 20:05 on 15 Mar 2005

Re: shared memory
Perrin Harkins 20:14 on 15 Mar 2005

Re: shared memory
=?ISO-8859-1?Q?Andr=E9_Warnier?= 22:26 on 15 Mar 2005

Re: shared memory
Perrin Harkins 22:31 on 15 Mar 2005

Re: shared memory
=?ISO-8859-1?Q?Andr=E9_Warnier?= 23:26 on 15 Mar 2005

Re: shared memory
Jonathan Vanasco 23:40 on 15 Mar 2005

Re: shared memory
Eric Wilhelm 23:50 on 15 Mar 2005

Re: shared memory
Perrin Harkins 00:29 on 16 Mar 2005

Re: shared memory
Scott Gifford 03:29 on 16 Mar 2005

Re: shared memory
William McKee 14:36 on 18 Mar 2005

Re: shared memory
Perrin Harkins 00:30 on 16 Mar 2005

Re: shared memory
jonathan vanasco 00:40 on 16 Mar 2005

Re: shared memory
Perrin Harkins 00:50 on 16 Mar 2005

Re: shared memory
Ofer Nave 01:20 on 16 Mar 2005

Re: shared memory
jonathan vanasco 01:56 on 16 Mar 2005

Re: shared memory
Perrin Harkins 01:06 on 17 Mar 2005

Generated at 16:59 on 18 Mar 2005 by mariachi v0.52