Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

FastCGI?

by Andy (Novice)
on Sep 21, 2002 at 06:26 UTC ( #199709=perlquestion: print w/ replies, xml ) Need Help??
Andy has asked for the wisdom of the Perl Monks concerning the following question:

By using FastCGI (.fcgi) does that automaticaly increase the speed of a perl script or do you need to use FastCGI functions. FastCGI makes it so the perl script does not have to be compiled everytime it is run, no? Thanks in advance.

Comment on FastCGI?
Re: FastCGI?
by adrianh (Chancellor) on Sep 21, 2002 at 09:13 UTC

    Warning: I do not use FastCGI. My understanding of it's functionality may be wrong. Please take with appropriate sized salt particles

    Short answer: No.

    Longer answer...

    As I understand FastCGI operates by separating out the one-time initialisation code from the per-request code.

    Your FastCGI script then does the one-time initialisation once, then sits there taking requests and passing them onto the per-request code.

    You get the speedup by only running the script "once" (it just sits there forever in a infinite loop serving requests) so you avoid the perl compilation hit, and the one-time initialisation hit.

    So, unless you rewrite you code in the form of:

    initialise(); while(FCGI::accept() >= 0) { serve_request(); };

    you won't get any speed advantage.

Re: FastCGI?
by Aristotle (Chancellor) on Sep 21, 2002 at 09:59 UTC
    If you want to automatically boost the speed of cleanly(!) written CGI scripts, you should probably have a look at mod_perl and its Apache::Registry handler instead. Even for sloppily coded scripts, some gains may be had using the Apache::PerlRun handler, albeit not as much.

    Makeshifts last the longest.

Re: FastCGI?
by vek (Prior) on Sep 21, 2002 at 15:39 UTC
    If installing mod_perl is an option for you, I heartily second Aristotle's comments regarding Apache::Registry. I've seen awesome performance gains when running vanilla CGI scripts with Apache::Registry. You'll have to make sure your CGI scripts are pretty strictly coded however so there may be some "tweaking" required to get them to run under Apache::Registry. You might want to check out cgi to mod_perl Porting on perl.apache.org.

    -- vek --
Re: FastCGI?
by samtregar (Abbot) on Sep 21, 2002 at 22:32 UTC
    Yes. By using FastCGI you will save the per-request initialization cost of running a normal CGI. This includes the time it takes to load the Perl interpreter and the time it takes to compile your script. In terms of performance enhancement FastCGI offers basically the same speedup as mod_perl. However, mod_perl also allows you to access the Apache API which gives you a whole load of capabilities that are not available in CGI or FastCGI.

    -sam

      But can you do this without re-writing into the FastCGI API - which was the original question.

      (Just want to find out if my reply was a lie :-)


      Updates:

      • 20020924 - I assume by this node's reputation I was lying in some respect :-) Can somebody tell me where I was wrong? Ta.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://199709]
Approved by Zaxo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2014-07-30 14:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls