Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation


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.

Replies are listed 'Best First'.
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

    -- 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.


      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 :-)


      • 20020924 - I assume by this node's reputation I was lying in some respect :-) Can somebody tell me where I was wrong? Ta.
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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://199709]
Approved by Zaxo
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2018-06-23 19:58 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.