[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: Many questions
From:       Stas Bekman <sbekman () iil ! intel ! com>
Date:       1999-09-29 12:54:24
[Download RAW message or body]


I'll try to answer some of the questions

> 3. Is it a good idea at the end of the script to clear the hash - in a
> perspective of mod_perl. The hash may become very large ?
> -->  %hash = ();

It's a good idea to initialize all the variables before using them (in any
language!!!), unless you want to use the variable as a cache within the
same process between requests, like file modification cache

> HINT : try this to see memory usage of httpd deamons including SHARED
> memory. You can't see it with "ps".
> 
> top -b -n 1 | grep -e "httpd\|PID" | cut -b '0-5,24-40'

This is very platform specific, there are many different top(1)
implementations and --options. 

e.g. see my reply from yesterday where I use the GTop module to show the
size of the memory (I know its C library isn't not fully ported to all
platforms :(

> 4. What is the best way to implement something like NextPage, PrevPage
> (+PageSize) for the DBI query. (I'm with PostgresSQL but for other too).
> 
> Something like ADO/IIS similar methods.
> SELECT ... LIMIT,OFFSET ... stuff ?!?!

Dunno about PostgresSQL, it works with mysql, make sure you always preceed
this call with select count(*) to update the number of matched records
(since between 2 clicks the number of matches can shrink and grow)

> 6. Is there some docs how to write SHARED memory aware script for
> mod_perl ? Or this is impossible ? just curios :")

Script cannot be aware if SHARED memory. OS can be aware of the SHARED
memory. With mod_perl it means that the more modules you preload at the
server startup - the more memory will be shared, since when the child is
being forked it inherits all the parents memory, without the last being
duplicated. The moment the child modifies some variables inside the code,
the memory page that contains this variable will be dupicated and copied
into this child process space. Taking into account perl's nature, where
there is no separation between data and text (code) pages and all the
memory being allocated at the heap, it's very hard to keep the memory
shared. 

You can control it by killing the processes from time to time, and when
the new child is being spawned it'll get all the memory from the parent
again and the story starts from the beginning (pages become dirty, copied
and memory unsharing happens). 

A few ways to systemize the killing of the process is by keeping the
number of MaxRequests under some number that you find out by trial,
Apache::SizeLimit which can control only the absolute (virtual) size of
the process, Apache::GTopLimit that does the same as Apache::SizeLimit
plus knows to kill the processes based on the Shared memory lower limit.

Probably the last module is the one you want. It's will be released with
mod_perl-1.22. Meanwhile you can get it from the mod_perl CVS (e.g from:
http://dev.apache.org/from-cvs/modperl/)

P.S. based on some of the questions you've asked, you would want to read
the available documentation at perl.apache.org. Many of these questions
have been already answered in the various FAQs at the site (not all of
them). Please, get advised by these first. Thank you. 

Enjoy
_______________________________________________________________________
Stas Bekman  mailto:sbekman@iil.intel.com    www.singlesheaven.com/stas  
Perl,CGI,Apache,Linux,Web,Java,PC at  www.singlesheaven.com/stas/TULARC
www.apache.org  & www.perl.com  == www.modperl.com  ||  perl.apache.org
single o-> + single o-+ = singlesheaven    http://www.singlesheaven.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic