in reply to Fast CGI

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

Replies are listed 'Best First'.
Re: Re: Fast CGI
by Sihal (Pilgrim) on Oct 21, 2002 at 11:21 UTC
    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

        In addition to the things IlyaM mentions, I'd add,

        6. FastCGI processes can run on a separate computer from the web server.
        All FastCGI does it take an HTTP request and send it, with appropriate delimiters, to another socket and then wait for a response. What makes it fast is that you can then structure your program like this:
        Initialization ... while (new CGI::Fast) { main CGI loop }
        You can thus service many requests without the all the overhead of process start-up, Perl compilation, DB opens, etc. Except for separating the initialization code, FastCGI usually doesn't require any changes to your program. You often do have to make some more changes for mod_perl, although usually not much.