You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Torsten Förtsch <to...@gmx.net> on 2011/11/01 09:27:12 UTC

Re: suggestions for dynamic run-time configuration?

On Monday, 31 October 2011 22:28:32 E R wrote:
> To reduce the impact this checking would have on serving requests I
> was thinking of checking only every N requests (i.e. N = 10) and/or
> performing the check as part of the cleanup handler.

I wouldn't do that. Suppose your server is under load so that N workers 
are needed. Then the load drops so that M workers are needed where M<<N. 
Depending on your config N-M workers may linger on for quite a while not 
getting any request. Now you change the config. If you check only every X 
request cycles for an update the new config may take a long time to make 
it to all the workers.

> Any suggestions / recommendations or alternatives for a mod-perl
> environment?

Have a look at MMapDB on CPAN. It maps a (prepared binary) file read-only 
into RAM. Thus, the memory is shared among all of it's clients. Access is 
similar to hash/array lookup in Perl. Updates replace the whole file and 
set a flag in the header of the old file that may still be mapped by a 
number of clients marking the DB as invalid. Checking if there is new 
config is hence a simple RAM lookup, no syscall or similar. Only if the 
flag indicates the currently mapped DB is out-dated further steps are 
taken to map the new one. The DB file itself is organized to allow for 
binary search. So, lookup is quite fast. If you store larger chunks of 
data another feature comes in handy. Upon access data is not copied. What 
you get is a read-only variable (a PV) that points directly to the shared 
memory. If you pass around references in your program then this value 
will never be copied. There is one more thing, the DB stores also the 
utf8 flag for its data. So, the strings C<do{use bytes; "förtsch"}> and 
C<do{use utf8; "förtsch"}> are stored as 2 different things and you get 
them out as such.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: suggestions for dynamic run-time configuration?

Posted by E R <pc...@gmail.com>.
2011/11/1 Torsten Förtsch <to...@gmx.net>:
> On Monday, 31 October 2011 22:28:32 E R wrote:
> ...
>> Any suggestions / recommendations or alternatives for a mod-perl
>> environment?
>
> Have a look at MMapDB on CPAN. ...

That's a very interesting module - thanks for the pointer!