You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Didier Godefroy <dg...@ulysium.net> on 2000/11/19 03:10:38 UTC

CGI scripts & mod_perl

Quick (and maybe stupid) question(s):

How do we make sure regular CGI scripts are using mod_perl???
Is there a way to find out?
Is there anything to modify to make them work with mod_perl??

-- 
Didier Godefroy
mailto:dg@ulysium.net


Re: CGI scripts & mod_perl

Posted by Ruben I Safir <ru...@wynn.com>.
> 
> When you're *really* good with mod_perl, you abandon Apache::Registry
> and move up to writing handlers or using embedded templating systems
> like EmbPerl, Mason, or Template Toolkit.

Actually, if your using EMBPERL, why even BOTHER with the CGI interface
at all.

But I think that EMBPERL uses CGI.pm.  I generally teach CGI for ten
minutes and then jump straight into therorical Mod_perl and into
Practical EMBPERL.


Ruben
http://www.mrbrklyn.com

Re: CGI scripts & mod_perl

Posted by Ruben I Safir <ru...@wynn.com>.
Find the time to READ the documentation ....

Tonight would be a good nite.

Ruben
http://www.mrbrklyn.com

> At the moment, I'm just trying to get mod_perl to work and have users'
> scripts use it. I haven't had time to read docs on how to use it, only
> enough to get it going.
> Will it speed up regular scripts?
> Will it reduce the strain on system resources?
> Can I force existing scripts to use it with only a <Files> section? without
> modifying any scripts?
> How can I get confirmation that scripts are actually using it????
> 
> --
> Didier Godefroy
> mailto:dg@ulysium.net
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: modperl-unsubscribe@apache.org
> For additional commands, e-mail: modperl-help@apache.org

Re: Apache::Registry vs. Handlers

Posted by Robin Berjon <ro...@knowscape.com>.
At 15:10 19/11/2000 -0700, E.S. wrote:
>> on 11/19/00 6:04 PM, Randal L. Schwartz at merlyn@stonehenge.com uttered the
>> > When you're *really* good with mod_perl, you abandon Apache::Registry
>> > and move up to writing handlers or using embedded templating systems
>> > like EmbPerl, Mason, or Template Toolkit.
>> 
>Question...
>
>All other things being equal, what's the general performance difference
>between writing your own handlers or using a templating system vs. using
>your scripts under Apache::Registry?  I've been running my old CGI scripts
>under Apache::Registry for awhile now, and they seem to be pretty speedy;
>what do I have to gain by doing it the "right" way?

You ask a difficult -- if not impossible -- question. The performance of
templating systems depends on what features they have, and on what features
you use. Comparing them in terms of raw performance beyond the simple Hello
World is practically meaningless. One usually chooses a templating system
based on whether it supports feature x, y or z, and whether one likes the
syntax/model it uses.

As for CGI/Registry vs handlers, well.... I prefer handlers because what I
did in CGI lived mostly in modules anyway, and it fits the way I "do
things" better. If your CGIs are doing a lot of print()s, then I'd
definitely move to a templating system, perhaps in addition to modules
because it'll make your life easier and your code cleaner. Otherwise, if
you're happy with the way things work for you now, don't bother changing.
Just remember that there's more than the content handler if you need
functionality for other things related to your server, such as
authentication or logging.

-- robin b.
Machines take me by surprise with great frequency. -- Alan Turing


Re: Apache::Registry vs. Handlers

Posted by Stas Bekman <st...@stason.org>.
On Mon, 20 Nov 2000, Gunther Birznieks wrote:

> Stas already ran benchmarks. Search the previous posts if he didn't include 
> them in the guide.

http://perl.apache.org/guide/performance.html#Apache_Registry_PerlHandler_vs_

> At 03:10 PM 11/19/2000 -0700, E.S. wrote:
> 
> > > on 11/19/00 6:04 PM, Randal L. Schwartz at merlyn@stonehenge.com 
> > uttered the
> > > following:
> > >
> > > > When you're *really* good with mod_perl, you abandon Apache::Registry
> > > > and move up to writing handlers or using embedded templating systems
> > > > like EmbPerl, Mason, or Template Toolkit.
> > >
> >Question...
> >
> >All other things being equal, what's the general performance difference
> >between writing your own handlers or using a templating system vs. using
> >your scripts under Apache::Registry?  I've been running my old CGI scripts
> >under Apache::Registry for awhile now, and they seem to be pretty speedy;
> >what do I have to gain by doing it the "right" way?
> >
> >Thanks..
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: modperl-unsubscribe@apache.org
> >For additional commands, e-mail: modperl-help@apache.org
> 
> __________________________________________________
> Gunther Birznieks (gunther.birznieks@extropia.com)
> eXtropia - The Web Technology Company
> http://www.extropia.com/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: modperl-unsubscribe@apache.org
> For additional commands, e-mail: modperl-help@apache.org
> 
> 



_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:stas@stason.org   http://apachetoday.com http://jazzvalley.com
http://singlesheaven.com http://perlmonth.com   perl.org   apache.org



Re: Apache::Registry vs. Handlers

Posted by Gunther Birznieks <gu...@extropia.com>.
Stas already ran benchmarks. Search the previous posts if he didn't include 
them in the guide.

At 03:10 PM 11/19/2000 -0700, E.S. wrote:

> > on 11/19/00 6:04 PM, Randal L. Schwartz at merlyn@stonehenge.com 
> uttered the
> > following:
> >
> > > When you're *really* good with mod_perl, you abandon Apache::Registry
> > > and move up to writing handlers or using embedded templating systems
> > > like EmbPerl, Mason, or Template Toolkit.
> >
>Question...
>
>All other things being equal, what's the general performance difference
>between writing your own handlers or using a templating system vs. using
>your scripts under Apache::Registry?  I've been running my old CGI scripts
>under Apache::Registry for awhile now, and they seem to be pretty speedy;
>what do I have to gain by doing it the "right" way?
>
>Thanks..
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: modperl-unsubscribe@apache.org
>For additional commands, e-mail: modperl-help@apache.org

__________________________________________________
Gunther Birznieks (gunther.birznieks@extropia.com)
eXtropia - The Web Technology Company
http://www.extropia.com/


Re: Apache::Registry vs. Handlers

Posted by Gunther Birznieks <gu...@extropia.com>.
At 10:42 PM 11/19/2000 -0800, spam@vancouver.yi.org wrote:
>[snip]
>
>Apache::Registry - use it only for backend or lowtraffic sites. It does
>not cache anything, so when you do databases, and files, can be bad to
>horrible to use. Using with small MySQL databases (50,000< records) you
>can get mediocre performance, cuz mysql connects require virtually no
>setup overhead. So if basically you have bunch of old code you have to
>throw up on the web and have no time this is the way to go.

What do you mean Apache::Registry caches nothing? You still get Apache::DBI 
and you can write your own package level caching mechanisms without too 
much problem.



Re: Apache::Registry vs. Handlers

Posted by sp...@vancouver.yi.org.
On Sun, 19 Nov 2000, E.S. wrote:

> All other things being equal, what's the general performance difference
> between writing your own handlers or using a templating system vs. using
> your scripts under Apache::Registry?  I've been running my old CGI scripts
> under Apache::Registry for awhile now, and they seem to be pretty speedy;
> what do I have to gain by doing it the "right" way?

Depends on implementation, and benchmarks, benchmarks... and benchmarks.
Tightly coded modules would be the fastest, and do them in perl perhaps
slowly translating them into C if you really want the
performance. However, flexibility here is last item on the list.

Templating system - written a few and all different, some real fast,
nearly as fast as custom modules others about 2 - 5 time slower, because
they are so flexible.

Apache::Registry - use it only for backend or lowtraffic sites. It does
not cache anything, so when you do databases, and files, can be bad to
horrible to use. Using with small MySQL databases (50,000< records) you
can get mediocre performance, cuz mysql connects require virtually no
setup overhead. So if basically you have bunch of old code you have to
throw up on the web and have no time this is the way to go.

So there,
	Pavel
--
Bask in the glow of the digital silence.
http://www.vancouver.yi.org


Apache::Registry vs. Handlers

Posted by "E.S." <ra...@omega2.com>.
> on 11/19/00 6:04 PM, Randal L. Schwartz at merlyn@stonehenge.com uttered the
> following:
> 
> > When you're *really* good with mod_perl, you abandon Apache::Registry
> > and move up to writing handlers or using embedded templating systems
> > like EmbPerl, Mason, or Template Toolkit.
> 
Question...

All other things being equal, what's the general performance difference
between writing your own handlers or using a templating system vs. using
your scripts under Apache::Registry?  I've been running my old CGI scripts
under Apache::Registry for awhile now, and they seem to be pretty speedy;
what do I have to gain by doing it the "right" way?

Thanks..



Re: CGI scripts & mod_perl

Posted by Didier Godefroy <dg...@ulysium.net>.
on 11/19/00 6:04 PM, Randal L. Schwartz at merlyn@stonehenge.com uttered the
following:

> Didier> Can I assume that whenever mod_perl is enabled that all existing perl
> Didier> scripts use it without any modification of any kind?
> 
> Not at all.  Apache::Registry is a good stop-gap, but you have to play
> by a number of useful and documented rules.
> 
> When you're *really* good with mod_perl, you abandon Apache::Registry
> and move up to writing handlers or using embedded templating systems
> like EmbPerl, Mason, or Template Toolkit.

At the moment, I'm just trying to get mod_perl to work and have users'
scripts use it. I haven't had time to read docs on how to use it, only
enough to get it going.
Will it speed up regular scripts?
Will it reduce the strain on system resources?
Can I force existing scripts to use it with only a <Files> section? without
modifying any scripts?
How can I get confirmation that scripts are actually using it????

-- 
Didier Godefroy
mailto:dg@ulysium.net


Re: CGI scripts & mod_perl

Posted by Vivek Khera <kh...@kciLink.com>.
>>>>> "GB" == Gunther Birznieks <gu...@extropia.com> writes:

GB> Apache::Registry programs are basically compatible with Velocigen,
GB> PerlEx, and SpeedyCGI acceleration. I think that's a huge
GB> commercial and open source advantage for anyone writing web
GB> programs for sale or open community use.

And most of them can still run as traditional fork/exec CGI's for the
occasion where you need to use it on another server.

I think I've written exactly *one* direct handler (other than for
hire), and that was just for learning how to do it.  I use Registry
all the time and see no reason not to continue using it.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/

Re: CGI scripts & mod_perl

Posted by Perrin Harkins <pe...@primenet.com>.
On Mon, 20 Nov 2000, Gunther Birznieks wrote:
> Most normal applications do not require every bit of speed eeked out
> of them that may be possible with an Apache handler. In the mod_perl
> guide, a reasonably fast machine (which most production mod_perl sites
> run on) shows very little time difference between a real-world app
> (what I would categorize the heavy Apache::Registry vs heavy hander)
> running in Apache::Registry versus being written as a handler.

We've already discussed this one into the ground, but for anyone here who
hasn't heard all this before, the main reason to use handlers instead of
Registry is to avoid the odd compromises caused by writing something that
is going to be wrapped in a generated package name and eval'ed into a
subroutine.  It's a pretty cool trick, but it's also limiting.  For
example, not being able to use subroutines unless you put them in an
external module is troublesome.

I also use handlers invoked as class methods so that I can do some
inheritance stuff in my modules.  I don't think Apache::Registry can deal
with that at this point.

- Perrin


Re: CGI scripts & mod_perl

Posted by Gunther Birznieks <gu...@extropia.com>.
At 03:04 PM 11/19/2000 -0800, Randal L. Schwartz wrote:
> >>>>> "Didier" == Didier Godefroy <dg...@ulysium.net> writes:
>
>Didier> on 11/19/00 4:55 PM, Ime Smits at ime@iae.nl uttered the following:
> >> | How do we make sure regular CGI scripts are using mod_perl???
> >> | Is there a way to find out?
> >>
> >> Check $ENV{MOD_PERL}, it should read something like "mod_perl/1.24".
>
>Didier> Can I assume that whenever mod_perl is enabled that all existing perl
>Didier> scripts use it without any modification of any kind?
>
>Not at all.  Apache::Registry is a good stop-gap, but you have to play
>by a number of useful and documented rules.
>
>When you're *really* good with mod_perl, you abandon Apache::Registry
>and move up to writing handlers or using embedded templating systems
>like EmbPerl, Mason, or Template Toolkit.

I do not consider Apache::Registry a stop gap. Maybe something like 
Apache::PerlRun is. The "rules" that you have to play by are also quite 
similar to the rules you would have to play by when writing a handler anyway.

Apache::Registry programs are basically compatible with Velocigen, PerlEx, 
and SpeedyCGI acceleration. I think that's a huge commercial and open 
source advantage for anyone writing web programs for sale or open community 
use.

Most people who write applications that require the use of mod_perl as 
opposed to using mod_perl as an option are shooting themselves in the foot 
as much as people who write applications that can only run in CGI 
mode.  There are occasional exceptions of course (eg AxKit makes reasonable 
use of Apache as a low-level system).

Most normal applications do not require every bit of speed eeked out of 
them that may be possible with an Apache handler. In the mod_perl guide, a 
reasonably fast machine (which most production mod_perl sites run on) shows 
very little time difference between a real-world app (what I would 
categorize the heavy Apache::Registry vs heavy hander) running in 
Apache::Registry versus being written as a handler.

The use of Apache::args and Apache::Request::param seem to provide a better 
bet for the code optimization money than simply moving out of 
Apache::Registry to a handler().







Re: CGI scripts & mod_perl

Posted by "Randal L. Schwartz" <me...@stonehenge.com>.
>>>>> "Didier" == Didier Godefroy <dg...@ulysium.net> writes:

Didier> on 11/19/00 4:55 PM, Ime Smits at ime@iae.nl uttered the following:
>> | How do we make sure regular CGI scripts are using mod_perl???
>> | Is there a way to find out?
>> 
>> Check $ENV{MOD_PERL}, it should read something like "mod_perl/1.24".

Didier> Can I assume that whenever mod_perl is enabled that all existing perl
Didier> scripts use it without any modification of any kind?

Not at all.  Apache::Registry is a good stop-gap, but you have to play
by a number of useful and documented rules.

When you're *really* good with mod_perl, you abandon Apache::Registry
and move up to writing handlers or using embedded templating systems
like EmbPerl, Mason, or Template Toolkit.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<me...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Re: CGI scripts & mod_perl

Posted by Didier Godefroy <dg...@ulysium.net>.
on 11/19/00 4:55 PM, Ime Smits at ime@iae.nl uttered the following:

> | How do we make sure regular CGI scripts are using mod_perl???
> | Is there a way to find out?
> 
> Check $ENV{MOD_PERL}, it should read something like "mod_perl/1.24".

Can I assume that whenever mod_perl is enabled that all existing perl
scripts use it without any modification of any kind?

I tried this in a simple script on both systems where I installed mod_perl
and there is nothing in that variable on either system.
Isn't there any way to find out if mod_perl actually works?
I see nothing special in any logs about this, but a status and info on
apache shows mod_perl enabled, and the few perl directives I inserted in the
httpd.conf aren't making a fuss, so I assume mod_perl is parsing them
properly...

-- 
Didier Godefroy
mailto:dg@ulysium.net


Re: CGI scripts & mod_perl

Posted by Ime Smits <im...@iae.nl>.
| How do we make sure regular CGI scripts are using mod_perl???
| Is there a way to find out?

Check $ENV{MOD_PERL}, it should read something like "mod_perl/1.24".

Ime