Re: Sharing read/WRITE data between threads? [EXT]

2021-08-25 Thread David Booth
Thank you Brad, Jacques and James, for your thoughtful suggestions.  I 
think Brad is right: I should see if I can figure out a different 
approach, instead of trying to do this.  It's looking like it would be 
more trouble than it's worth.  But I'm glad to know about those other 
options in case I need them!


Thanks,
David Booth

On 8/25/21 7:56 AM, James Smith wrote:

The other problem with sharing writable data in "memory" is that it would not 
necessarily shared between multiple server instances. We run multiple mod_perl instances 
for reliability. Agree with other posters either use something like redis or memcache 
(possibly backed with a database).


-Original Message-
From: David Booth 
Sent: 25 August 2021 00:51
To: modperl 
Subject: Sharing read/WRITE data between threads? [EXT]

I am using Apache/2.4.41 (Ubuntu), with mod_perl.  Apache uses multiple threads, and I 
want to share read/WRITE data between threads.  (I.e., I want to be able to modify some 
shared data in one thread, such that other threads can see those changes.)  In 
"Practical mod_perl" Stas Bekman describes how to share read-only data between 
threads, but says nothing about how to share WRITABLE data between threads.

Any clues about how this can be done?  I've searched high and low and found 
nothing.  I will also want to know what mechanisms are available to coordinate 
access to that shared data, such as locks or semaphores.

I also posted this message to StackOverflow, but got no response so far:
https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_68901260_how-2Dto-2Dshare-2Dread-2Dwrite-2Ddata-2Din-2Dmod-2Dperl-2Dapache2=DwICaQ=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo=oH2yp0ge1ecj4oDX0XM7vQ=qpyZVoG2Lx8wqNIB_pQ9wXQkohMh_5Q0HVZmgqmlSbs=oUnmv2w8aVNzfIni8nxA0CFh-xrZv1GS8jFquKbzsQM=

Any help would be appreciated!

Thanks,
David Booth





RE: Sharing read/WRITE data between threads? [EXT]

2021-08-25 Thread James Smith
The other problem with sharing writable data in "memory" is that it would not 
necessarily shared between multiple server instances. We run multiple mod_perl 
instances for reliability. Agree with other posters either use something like 
redis or memcache (possibly backed with a database).


-Original Message-
From: David Booth  
Sent: 25 August 2021 00:51
To: modperl 
Subject: Sharing read/WRITE data between threads? [EXT]

I am using Apache/2.4.41 (Ubuntu), with mod_perl.  Apache uses multiple 
threads, and I want to share read/WRITE data between threads.  (I.e., I want to 
be able to modify some shared data in one thread, such that other threads can 
see those changes.)  In "Practical mod_perl" Stas Bekman describes how to share 
read-only data between threads, but says nothing about how to share WRITABLE 
data between threads.

Any clues about how this can be done?  I've searched high and low and found 
nothing.  I will also want to know what mechanisms are available to coordinate 
access to that shared data, such as locks or semaphores.

I also posted this message to StackOverflow, but got no response so far:
https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_68901260_how-2Dto-2Dshare-2Dread-2Dwrite-2Ddata-2Din-2Dmod-2Dperl-2Dapache2=DwICaQ=D7ByGjS34AllFgecYw0iC6Zq7qlm8uclZFI0SqQnqBo=oH2yp0ge1ecj4oDX0XM7vQ=qpyZVoG2Lx8wqNIB_pQ9wXQkohMh_5Q0HVZmgqmlSbs=oUnmv2w8aVNzfIni8nxA0CFh-xrZv1GS8jFquKbzsQM=
 

Any help would be appreciated!

Thanks,
David Booth



-- 
 The Wellcome Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE.

Re: Sharing read/WRITE data between threads?

2021-08-25 Thread Jacques Deguest
Or you can also consider using IPC::Shareable
 if your system supports IPC.

Jacques Deguest

On 2021/08/25 17:11, Brad Van Sickle wrote:
> I've shared read-only data across threads many times a cheap and easy
> caching mechanims, but as I'm sure you've found in your research, the
> "copy-on-write" methodology employed by mod_perl prevents you from
> doing that for mutable data and I'm not aware of a way around that
> without fundamental changes to mod_perl itself.
>
> There are some very good reasons that mod_perl is architected that
> way.  You may very well have a specific use case that makes sharing
> mutable data in memory for a threaded application desirable, but I
> know that oftentimes when I've  tried to find ways to workaround a
> fundamental architectural element in a toolset, the best solution for
> me has ultimately been to rethink my approach rather than to wrestle
> the toolset into submission.
>
> In short, and although this isn't what you asked and I know next to
> nothing about your project, constraints or requirements... it sounds
> like you might want to consider a cache server
> (Redis/Varnish/Elasticache/etc...) and then solve the problem and
> proactively notify subscribed threads of changes if you need to.
>
>
>
>
> On 8/24/2021 7:50 PM, David Booth wrote:
>> I am using Apache/2.4.41 (Ubuntu), with mod_perl.  Apache uses
>> multiple threads, and I want to share read/WRITE data between
>> threads. (I.e., I want to be able to modify some shared data in one
>> thread, such that other threads can see those changes.)  In
>> "Practical mod_perl" Stas Bekman describes how to share read-only
>> data between threads, but says nothing about how to share WRITABLE
>> data between threads.
>>
>> Any clues about how this can be done?  I've searched high and low and
>> found nothing.  I will also want to know what mechanisms are
>> available to coordinate access to that shared data, such as locks or
>> semaphores.
>>
>> I also posted this message to StackOverflow, but got no response so far:
>> https://stackoverflow.com/questions/68901260/how-to-share-read-write-data-in-mod-perl-apache2
>>
>>
>> Any help would be appreciated!
>>
>> Thanks,
>> David Booth



OpenPGP_signature
Description: OpenPGP digital signature


Re: Sharing read/WRITE data between threads?

2021-08-25 Thread Brad Van Sickle
I've shared read-only data across threads many times a cheap and easy 
caching mechanims, but as I'm sure you've found in your research, the 
"copy-on-write" methodology employed by mod_perl prevents you from doing 
that for mutable data and I'm not aware of a way around that without 
fundamental changes to mod_perl itself.


There are some very good reasons that mod_perl is architected that way.  
You may very well have a specific use case that makes sharing mutable 
data in memory for a threaded application desirable, but I know that 
oftentimes when I've  tried to find ways to workaround a fundamental 
architectural element in a toolset, the best solution for me has 
ultimately been to rethink my approach rather than to wrestle the 
toolset into submission.


In short, and although this isn't what you asked and I know next to 
nothing about your project, constraints or requirements... it sounds 
like you might want to consider a cache server 
(Redis/Varnish/Elasticache/etc...) and then solve the problem and 
proactively notify subscribed threads of changes if you need to.





On 8/24/2021 7:50 PM, David Booth wrote:
I am using Apache/2.4.41 (Ubuntu), with mod_perl.  Apache uses 
multiple threads, and I want to share read/WRITE data between threads. 
(I.e., I want to be able to modify some shared data in one thread, 
such that other threads can see those changes.)  In "Practical 
mod_perl" Stas Bekman describes how to share read-only data between 
threads, but says nothing about how to share WRITABLE data between 
threads.


Any clues about how this can be done?  I've searched high and low and 
found nothing.  I will also want to know what mechanisms are available 
to coordinate access to that shared data, such as locks or semaphores.


I also posted this message to StackOverflow, but got no response so far:
https://stackoverflow.com/questions/68901260/how-to-share-read-write-data-in-mod-perl-apache2 



Any help would be appreciated!

Thanks,
David Booth