perl - Using shared memory in mod_perl environment -


i have requirement wherein

  1. i have place data structure (perl hash) in memory, each http process (running perl script) use hash.

  2. the hash structure around 300 mb.

  3. the environment mod_perl

i thought of creating module load @ apache start creates hash in shared region , returns reference it.

can please comment on behaviour, or suggest alternative solutions. please point resources check examples.

if place huge hash data on mod_perl memory, mod_perl parent process reads @ server startup phase.

in first, create your/hugedata.pm on @inc directory.

package your::hugedata;  our %dictionary = (     .... ); 

next, apache process reads on startup.

# in apache.conf (or anywhere apache config file) perlmodule your::hugedata 

then script can use %your::hugedata::dictionary package variable.

# in mod_perl handler script or modperl::registry (cgi emulate) script. use your::hugedata; ... $tokyo = $your::hugedata::dictionary{tokyo}; 

when use prefork mpm on linux apache, os prefers "copy on write" mechanism. forked child processes see parent proces'es data if read data. in other words, there may not waste memory using.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -