darshan_atha has asked for the wisdom of the Perl Monks concerning the following question:

hi monks. i have written a code in perl using simple cgi module now i want it to convert using fast cgi in place of cgi what all thing i should take into consideration how much code i should change.I read some docs but could't find much can anybody help me. thanx.

Replies are listed 'Best First'.
Re: Fast CGI
by nothingmuch (Priest) on Oct 21, 2002 at 09:15 UTC
    The basic principal is that your program never stops running, but instead blocks on a loop, and continues it's progress whenever a new request is needed.
    This is ment to aid in initializing generally unchanging things only once for several request, like database connections...

    What you need to make sure is that no information in the initialization part of the program is oriented towards any client in particular, and that everything is kept enclosed and secured - objects destroyed and cleaned up, and so forth.. Generally the loop scope should take care of this...

    Update: I forgot to mention that CGI::Fast inherits from CGI, which is more thoroughly documented. Their behavior is the same in terms of data processing, so the migration from CGI::Simple to CGI should be very similar if not identical to the migration to CGI::Fast...

    You may also be interested in mod_perl.

    -nuffin
    zz zZ Z Z #!perl
      By the way, what is the difference between mod_perl and fastCGI ? I mean I know how mod_perl works, but how does FastCGI? What are the differences ?
        mod_perl lets you to embed Perl interpretator in Apache. FastCGI allows to run any application as a daemon which communicates with web server. Main differences (beware that I don't use FastCGI myself and run my web programms under mod_perl so I can be wrong in some details):
        1. mod_perl is highly coupled with Apache and gives your Perl applications access to its internals what impossible with FastCGI
        2. mod_perl is for Apache only. FastCGI supports other web servers as well
        3. mod_perl is for Perl only. FastCGI is not limited to Perl
        4. Since FastCGI runs your program as a separate daemon it can run under different UID/GID than web server. FastCGI may be more flexiable when it comes to dealing with security polices.
        5. Probably other things I forgot to mention or I don't know.
        Personally I prefer mod_perl (mostly because of #1).

        --
        Ilya Martynov, ilya@iponweb.net
        CTO IPonWEB (UK) Ltd
        Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
        Personal website - http://martynov.org