[sf-perl] CGI working

Daniel Lo woof at danlo.com
Sat Mar 1 21:39:42 PST 2008

Hello Neil,

Plain generic Perl CGI programs will not stay in memory between invocations.
This is a plus in some regards.

1. Any attempts to affect the next invocation (hacking) will fail, because the
program starts fresh.
2. No memory leaks (well, nothing you have to worry about).
3. It leaves memory! (If your application, is called once every 20 minutes, it
is not hogging memory!)
4. Easier to debug.
5. Widely supported.  (What server doesn't do this...)
6. If your program is called often, the harddisk sectors containing the program
are likely to stay in the OS cache, so its not that painful)
7. Less problems (sometimes).  You don't have issues with programs that run a
long time. (Not giving up database connections, memory hogs, caching issues,
un-initialized variables between calls, etc..)


There are other ways around this.  FastCGI (FastCGI.com) is a simple wrapper
that is easy to use (FCGI.pm/CGI.pm).  And there is mod_perl.

You may want to check out Catalyst: http://catalyst.perl.org/


Saturday, March 1, 2008, 9:17:28 PM, you wrote:

> Are you saying that using plain Perl CGI programs in Apache means that the
> application (really the script, in this case) will NOT stay in memory
> between invocations?  That's a bummer for me.

> Neil Heller

> -----Original Message-----
> From: sanfrancisco-pm-bounces+nheller=silcon.com at pm.org
> [mailto:sanfrancisco-pm-bounces+nheller=silcon.com at pm.org] On Behalf Of
> Michael Friedman
> Sent: Saturday, March 01, 2008 6:10 PM
> To: San Francisco Perl Mongers User Group
> Subject: Re: [sf-perl] CGI working

> If you are using mod_perl (or a similar setup for non-apache  
> webservers) it will stay in memory between invocations. If you are  
> just using CGI.pm and launching the program from a directory path,  
> then it gets called anew each time.

> The CGI spec says that the webserver will call out to the program anew  
> every time. That is the same no matter what language the program is  
> written in: perl, python, C, bash shell, etc. It's a really expansive  
> feature, since you can do anything you can do on the machine from the  
> webserver, but it's a bit slow due to the repeated instantiations. ;-)

> You should check the documentation for your webserver about how it  
> handles CGI scripts for further details.

> -- Mike

> On Mar 1, 2008, at 5:32 PM, Neil Heller wrote:

>> I looked and looked unsuccessfully to directly find the answer to my
>> question.  I was hoping someone here knew off the top of his head.
>> When a Perl-CGI program is launched, does it stay in memory as a  
>> singularity
>> (like J2EE) or does it instantiate anew each time it's called?
>> _______________________________________________
>> SanFrancisco-pm mailing list
>> SanFrancisco-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm

> ---------------------------------------------------------------------
> Michael Friedman                     HighWire Press
> Phone: 650-725-1974                  Stanford University
> FAX:   270-721-8034                  <friedman at highwire.stanford.edu>
> ---------------------------------------------------------------------

> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm

> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm

Best regards,
 Daniel                            mailto:woof at danlo.com

More information about the SanFrancisco-pm mailing list