Pramod:
We are actually going to be generalizing it and releasing it (maybe) but
we need to get approval first, so can't just send the code :) It'll
probably happen in a few weeks though.
So here's what you have to do:
- Clean up the systems-level modules (like database stuff, base libraries)
and packages that are used a lot (stuff like date conversions and other
random operations) by making sure they pass "perl -w" and "use strict"
- Install mod_perl into Apache
- Make Apache handle CGIs through PerlRun with PerlRunOnce Off
- Put the clean packages that you want to keep in memory in a startup.pl
file that is PerlRequire'd by the httpd.conf file
- Write the handler (more details below)
- After the PerlRequire statement, install the handler as a
PerlCleanupHandler
That should do it.
Here are the details about the cleanup handler in pseudocode:
BEGIN {
load the list of packages that are in memory now into a global variable
}
sub handler {
look through the list of packages in memory and see if there are entries
in the global variable
if not, then flush them out (code you can copy from PerlRun.pm in
mod_perl source)
after flushing it out, then clear the entry in %INC
}
The BEGIN {} makes it so that you NEED to load this handler after the
startup.pl stuff because otherwise the handler will flush the clean
packages you have listed in the startup.pl file.
Also, we actually wrote a database package that acts exactly like
Apache::DBI (but has some customized features) so we didn't end up using
the Apachage::DBI package. However, for persistent connections this might
be something that you want to look into.
I hope this makes sense. Let me know if you have any questions. If you can
wait a few weeks (2-3) you can just grab the handler from me :) Just so
you know, after all the optimizations that we have been able to
practically deal with (cleaning systems modules, that kind of thing) we
are getting 100%-400% speed increases. Pretty nice, huh?
Andrew Chen
Intern, Architecture
[EMAIL PROTECTED]
206-219-8445
The Cobalt Group, Inc.
On Tue, 25 Jul 2000, Pramod Sokke wrote:
> Hi Andrew,
>
> I've been following your mails regarding porting your CGIs to mod_perl on
> the mod_perl mailing list, but I got lost after a few mails. But I know
> that you celebrated success at the end of it all....another mod_perl sucess.
> Basically, the reason I'm writing to you now is because I have the exact
> same challenge as you had when you started this project - migrate CGIs to
> mod_perl. As with your case, our code is too dirty to use Apache::Registry,
> so I have to use Apache::PerlRun. Our code base is huge and our application
> is very database intense, in the sense that there are too many calls to the
> database.
> I would appreciate if you could tell me in as much detail as possible about
> how exactly you went about doing this migration. I know this is too much
> trouble for you, but you'll be helping another soul a lot :)
> I'm not in a big hurry, so you can take your time to write this up. It'll
> be really useful if you can give me as much details as possible. If you
> already have a document that you wrote about this, that would great too.
>
> Thanks in advance!
> -Pramod
>