This is a discussion on Re: Reducing memory usage using fewer cgi programs - modperl ; --- On Mon, 10/20/08, Carl Johnstone wrote: > From: Carl Johnstone > Subject: Re: Reducing memory usage using fewer cgi programs > To: "Michael Peters" , firstname.lastname@example.org > Cc: email@example.com > Date: Monday, October 20, 2008, 8:11 AM > >> ...
--- On Mon, 10/20/08, Carl Johnstone
> From: Carl Johnstone
> Subject: Re: Reducing memory usage using fewer cgi programs
> To: "Michael Peters"
> Cc: firstname.lastname@example.org
> Date: Monday, October 20, 2008, 8:11 AM
> >> I also use a PerlRequire startup.pl to preload most
> modules (CGI, DBI),
> >> but I thought that was only for quicker startup
> times and not for sharing
> >> memory. Is that correct?
> > Preloading helps with speed (you don't get the the
> initial loading hit for
> > a module the first time it's used in a specific
> process) but it can also
> > help with memory on certain OSs.
> Pre-loading *will* give you a longer startup time, as you
> have to pre-load
> all the modules before apache can start.
> However, as Michael says, the module would be loaded the
> first time a script
> used it anyway - so you'd have the same delay but in
> the middle of a request
> rather than at server start-up! Additionally you would have
> that delay in
> each child process that apache creates in the entire life
> of the server.
I was referring to script initialization (responding to that first request) and not the httpd daemon startup. Really, the only "startup"
that should be slower is when the whole httpd service is restarted (such as at server startup) since it would have to preload all modules for all standby daemons.
I would expect (or hope -- I don't really know) that any individual httpd daemons that get re-initialized later on automatically (when MaxRequestsPerChild is reached) would be done after the previous request so they are ready for the next request.
Something else I will do for my low-usage but "massive" scripts (those that have large memory structures and take several seconds to execute) is to place these in a non-mod_perl directory so I can be assured their memory usage goes away at the end of the response.