FAQ 3.19 How can I make my CGI script more efficient?
- From: PerlFAQ Server <comdog@xxxxxxxx>
- Date: Sun, 6 Nov 2005 17:03:01 +0000 (UTC)
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
3.19: How can I make my CGI script more efficient?
Beyond the normal measures described to make general Perl programs
faster or smaller, a CGI program has additional issues. It may be run
several times per second. Given that each time it runs it will need to
be re-compiled and will often allocate a megabyte or more of system
memory, this can be a killer. Compiling into C isn't going to help you
because the process start-up overhead is where the bottleneck is.
There are two popular ways to avoid this overhead. One solution involves
running the Apache HTTP server (available from http://www.apache.org/ )
with either of the mod_perl or mod_fastcgi plugin modules.
With mod_perl and the Apache::Registry module (distributed with
mod_perl), httpd will run with an embedded Perl interpreter which
pre-compiles your script and then executes it within the same address
space without forking. The Apache extension also gives Perl access to
the internal server API, so modules written in Perl can do just about
anything a module written in C can. For more on mod_perl, see
http://perl.apache.org/
With the FCGI module (from CPAN) and the mod_fastcgi module (available
from http://www.fastcgi.com/ ) each of your Perl programs becomes a
permanent CGI daemon process.
Both of these solutions can have far-reaching effects on your system and
on the way you write your CGI programs, so investigate them with care.
See
http://www.cpan.org/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/
.
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
.
- Prev by Date: Re: How to get html help of ActivePerl
- Next by Date: Re: MODIFIED DATE AN D TIME
- Previous by thread: FAQ 4.73 How do I print out or copy a recursive data structure?
- Next by thread: Re: FAQ 3.19 How can I make my CGI script more efficient?
- Index(es):
Relevant Pages
|