RE: ModPerl::RegistryLoader

"Deighan, John" <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
I don't know about ModPerl::RegistryLoader, but the simplest solution is just to "preload" the interpreters either manually or through a script whenever you restart Apache. In your httpd.conf file, you control how many interpreters are running and how many hits each interpreter handles before reloading that interpreter (it can be unlimited if you wish). If, e.g., you're configured to run 6 interpreters, to be sure they're all loaded, you will need to send 6 concurrent requests to the server - if you send requests serially, it might use the same interpreter to serve all 6 requests. In our case, we've set up a web page that is a frames page with multiple frames, each making the same request to the server. We also have a script that utilizes LWP::UserAgent to do basically the same thing.

FYI, our application consists of a single script which, depending on the parameters passed to it, can do many different things. Because of that, once that one script is loaded in an interpreter, there's nothing else to load. If you have many separate scripts, you can either do the above, but for each script. However, usually if you have many scripts, each script is quite small, but may load many Perl libraries (i.e. modules). Keep in mind that if you load a single script that loads, e.g. 10 Perl libraries, then when another script is required that uses some of those libraries, Perl will detect the libraries that have already been loaded and not load them again. For that reason, the other scripts should load very quickly so it may be sufficient to just preload the script that uses the most of these common libraries.

An httpd.conf configuration we often use is something like:

# Set up the settings for interpreters within mod_perl

PerlInterpStart 12
PerlInterpMax 12
PerlInterpMinSpare 12
PerlInterpMaxSpare 12
PerlInterpMaxRequests 2048

We've found that having a fixed number of interpreters at all times works best for us - we've had problems in the past where an interpreter is retired by Apache when the load temporarily drops, only to be started up when the load picks back up (usually within a very short amount of time), requiring a full reload and slowing down response. That's why the first 4 settings are all the same. You might want to look it up, but I believe that if PerlInterpMaxRequests is set to 0, an interpreter will take an unlimited number of hits without reloading. Reloading an interpreter, however, can help if you have memory leaks or other such "bad" things that accumulate over time.
________________________________________
From: Jiří Pavlovský [[email protected]]
Sent: Thursday, July 21, 2011 4:45 AM
To: [email protected]
Subject: ModPerl::RegistryLoader

Hello,

The documentation for "ModPerl::Registry" states: "Note that each httpd
process or "child" must compile each script once, so the first request
to one server may seem slow, but each request there after will be
faster. If your scripts are large and/or make use of many Perl modules,
this difference should be noticeable to the human eye."

I've indeed run into this as my service is not accessed so often so
typically the user requests reaches some httpd child which did not
compile the script yet. So user usually has to wait for the compilation.
In my case the difference is huge (2s versus tenths of ms) which makes
notable difference for the user experience for the various autocomplete
inputs etc.

So I was looking a solution and found ModPerl::RegistryLoader. I'm just
not sure I understand it completely. Is this the "compile once at
startup" solution? Do I just put " my $rlbb =
ModPerl::RegistryLoader->new();" into my startup file?


Thank you,
Jiri
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.