Re: Improving Perl Speeds in Apache
by mitd (Curate) on Sep 15, 2001 at 00:35 UTC
|
First I assume that you are using Perl, as is most common, to create CGI scripts.
This being the case you can start by installing mod_perl and begin by using the bundled Apache::Registry module which allows to run almost all legacy perl CGI scripts unaltered from within the mod_perl environment.
The speed enhancement is accomplished in two important ways:
- mod_perl 'pre-loads' perl.
- each apache process or child will only compile the script once
CGI execution speed increases of 400-1000% have been observed.
mitd-Made in the Dark
'My favourite colour appears to be grey.' | [reply] |
|
Plus, if there's a database involved, use shared database handles (Apache::DBI is useful for this). Oracle suggest this can make an order of magnitude difference in speed.
Andy.
| [reply] |
Re: Improving Perl Speeds in Apache
by blakem (Monsignor) on Sep 15, 2001 at 00:28 UTC
|
Assuming you are already using mod_perl (if not, that would
probably be my first suggestion unless you are using something like FastCGI or SpeedyCGI....) here is the mod_perl tuning guide.
I've found that the slowest part of many dynamic web sites is the interaction with the database. Optimizing your SQL queries and database setup tends to be time well spent....
-Blake
| [reply] |
Re: Improving Perl Speeds in Apache
by perrin (Chancellor) on Sep 15, 2001 at 00:23 UTC
|
Use a persistent Perl engine like mod_perl, FastCGI, or SpeedyCGI. Read the performance tuning documentation for mod_perl. Profile your code, find the slow parts, and fix them. | [reply] |
Re: Improving Perl Speeds in Apache
by oneiros (Scribe) on Sep 15, 2001 at 06:26 UTC
|
| [reply] |
Re: Improving Perl Speeds in Apache
by maverick (Curate) on Sep 15, 2001 at 05:06 UTC
|
Along with other's suggestions, take a look at a kernel level httpd for static content (Linux has a nice one), or move it to another server and reference it like <img src="http://images.foo.com/gif1.gif">.
Just decreasing the number of things that Apache, or the same machine has to serve, will help your performance and scalability.
Also, always including the width and height attributes in your image tags will help the 'percieved' speed at which the page loads, because if the browser knows the size of the images it can render the page while it is downloading the images.
/\/\averick
perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"
| [reply] |
|
Along with other's suggestions, take a look at a kernel level httpd for static content (Linux has a nice one)...
Right on Maverick! I had forgotten about user-space server which is strange since we just started using it recently.
One can find detail here KHTTPd.
mitd-Made in the Dark
'My favourite colour appears to be grey.'
| [reply] |
Re: Improving Perl Speeds in Apache
by Ven'Tatsu (Deacon) on Sep 15, 2001 at 10:29 UTC
|
While mod_perl and the like are great and all I would really strees looking at the speed the code it self exicutes.
In most cases the server process will not send any data, not even the HTTP responce headders, until all data from the CGI process has been read.
That means a pourly writen loop, even after most of the page has been sent to the server process, can chew up valuable seconds, especaly if you have any SQL querys inside a loop. | [reply] |
Re: Improving Perl Speeds in Apache
by toma (Vicar) on Sep 15, 2001 at 23:04 UTC
|
Often the problem with CGI program speed has to do
with print statement slowness. See
Re: Perl CGI and SSI speed. Other
articles in that thread suggest many other useful
speedups.
Benchmarking is a great way to find
problems in the speed of your code. If you benchmark
correctly, it is easy for others to help you speed
up critical sections of your code.
It should work perfectly the first time! - toma | [reply] |
Re: Improving Perl Speeds in Apache
by drifter (Scribe) on Sep 17, 2001 at 09:57 UTC
|
You might consider about taking a look at HTML::Mason,
from CPAN or http://www.masonhq.com,
which is a mod_perl related dynamic content module.
It might seem a bit awkward at the beginning but the speed
increase is nice, it has it's own caching magic of
components. | [reply] |