The Perl You Need to Know Special: Introduction to mod_perl Part 3
June 19, 2000
|
Like all gripping tales of conquering heroes and/or Godfathers, our story of
mod_perl is a trilogy. We conclude the mod_perl trilogy with some tricks and
sleight-of-hand with which you can squeeze a few extra processor cycles out
of your web server -- also known as optimizations. Specifically, we'll
look at some ways to take advantage of the mod_perl environment to better
optimize usage and, more importantly, re-usage of Perl scripts and database
requests.
|
Reuse and Recycle
If your mod_perl enabled
Apache
server only needed to execute your
Perl
scripts one time, forever, we probably wouldn't need this article.
Or mod_perl. Or the Internet, for that matter. So it's established that your
scripts need to run repeatedly, whether "repeatedly" means once
per day, once per minute, or ten times per second. Nobody likes doing the
same thing over and over, Apache included -- it's silly and inefficient to
repeat an entire task every time you need to reach a certain goal. This
brings us to the core purpose of optimization:
Suppose that you need to wash a sinkful of dirty dishes. You'll need hot
water from the tap to fill the sink and an open bottle of dish washing
detergent, preferably the kind that leaves your hands silky smooth. You
could turn on and off the tap for each dish, waiting for the water
to get hot each time, re-close and re-open the detergent bottle for each
dish, and so on. An onlooker would probably observe that you're not the
sharpest tool in the shed -- and they'd be right. But without optimizations,
this is exactly what we do with Apache everytime a Perl script is executed:
turn on and off the tap water for each dish, wait for the water to get hot,
re-open the detergent bottle, and so forth.
To get the most out of mod_perl, we need to think about how mod_perl re-uses
compiled code, and design a strategy that best balances the efficiencies of
re-using compiled code versus the costs in memory consumption. Understanding
mod_perl in this way means understanding the parent-child relationship, which
we mean in a purely server-centric way, and not at all in a Dr. Laura/John
Bradshaw/Benjamin Spock sort of way.
Contents:
Who's Your Daddy?
More Who's Your Daddy
Database Savoir Faire
Building the Optimized Beast
Conclusion and Resources
Conclusion
The Perl You Need to Know
Who's Your Daddy?
|