You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Garth Webb <ga...@zappos.com> on 2004/02/13 19:47:53 UTC

[OT] Re: Shared Module Vars, Missing Object Methods?

On Fri, 2004-02-13 at 10:26, Ged Haywood wrote:
[snip]
> > Since I'm building the code from scratch, I am currently using
> > Apache::Registry
> 
> If I were you I wouldn't do that either.
> 
> > My initial (newb) impression was that PerlRun is for quick porting,
> > Registry is more proper.
> 
> Nope.  Both are horrible hacks.

So what is a good alternative to Apache::Registry?  My impression was
that this is the thing to use unless you want the extra functionality of
something like HTML::Mason.   I read:

http://perl.apache.org/docs/1.0/guide/performance.html#Apache__Registry_PerlHandler_vs__Custom_PerlHandler

which shows Apache::Registry is slightly slower (but not by much) than
writing a custom Handler.  In my case I have 100's of scripts I'd have
to write custom handlers for which seems like a maintenance nightmare. 
If I wrote a generalized handler, I'd just be reinventing
Apache::Registry.  Has someone reinvented Apache::Registry in a way that
isn't a horrible hack?

-- 

 |- Garth Webb       -|
 |- garth@zappos.com -|

Re: [OT] Re: Shared Module Vars, Missing Object Methods?

Posted by Perrin Harkins <pe...@elem.com>.
On Tue, 2004-02-17 at 14:07, Garth Webb wrote:
> So my question is, what do you think is the better alternative to
> Apache::Registry?

There is nothing terribly wrong with Apache::Registry.  The main issue
is that it is emulating a CGI environment to provide backwards
compatibility, and there's no reason to do that for new development
unless you intend to support CGI.  If you aren't using them, the extra
moving parts for the emulation are just extra things that can go wrong
or cause problems.

There are certain specific drawbacks to the eval approach used by
Registry, which we have discussed before on the list, but none of them
are serious if you are following a good coding style.

> Do people really have conf files
> with 100's of <Location> directives?

Frankly, if you have 100s of scripts, your application architecture
needs reworking.  I typically have less than 10 handlers for an entire,
complex site, with each one representing a single application on the
site.

If I did have 100 handlers, I would use Apache::Dispatch, or generate my
httpd.conf file from a template.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Re: Shared Module Vars, Missing Object Methods?

Posted by Perrin Harkins <pe...@elem.com>.
On Tue, 2004-02-17 at 14:22, David Emery wrote:
> You might be looking for something more like this:
> 
> http://daemoninc.com/PersistentPerl/
> http://search.cpan.org/~horrocks/PersistentPerl-2.22/
> 
> I don't know if it's necessarily *better* than Apache::Registry, but I
> think in your situation it will give you a similar performance boost
> with somewhat less pain.

Sorry, no.  It's nearly identical to Apache::Registry in terms of the
kind of code that it tolerates.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Re: Shared Module Vars, Missing Object Methods?

Posted by David Emery <da...@skiddlydee.com>.
Garth Webb wrote:

> So my question is, what do you think is the better alternative to
> Apache::Registry?  If its bad enough that someone like me might have
> written a replacement, where is it?  Do people really have conf files
> with 100's of <Location> directives?  It seems to me that most people
> these days are using toolkits which take care of this URL location to
> script location automatically, (thus my original question).

You might be looking for something more like this:

http://daemoninc.com/PersistentPerl/
http://search.cpan.org/~horrocks/PersistentPerl-2.22/

I don't know if it's necessarily *better* than Apache::Registry, but I
think in your situation it will give you a similar performance boost
with somewhat less pain.


-- 
-dave


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Apache::Registry vs Other PerlHandlers (Was: Re: [OT] Re: Shared Module Vars, Missing Object Methods?)

Posted by petersm <pe...@venzia.com>.
Garth Webb <ga...@zappos.com> wrote
> 
> If anyone knows of any other simple C-based templating systems they use
> and like, I'd be interested to hear about it!

I really like HTML::Template. I know it's mostly perl based, but it is known
for being really fast. Plus there are several cacheing options that work with
mod_perl or regular CGI (since you said you need to support both). Plus,
there's the HTML::Template::JIT which compiles your templates down to machine
code, making it even faster.

Michael Peters
Venzia

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Apache::Registry vs Other PerlHandlers (Was: Re: [OT] Re: Shared Module Vars, Missing Object Methods?)

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hello again,

On Tue, 17 Feb 2004, Garth Webb wrote:

> Right now I think I might try to convert a select few of our most hit
> scripts into handlers to see if some performance can be gained.
> ...
> during high load days our 3 servers really break a sweat as it is. 

Could be worth mentioning that you might be able to change the
architecture to cut down the resource usage without too much change in
the configuration (and practically none in the code) by using proxy
and/or caching techniques.  These old chestnuts have been roasted here
many a time but there always seems to be another wrinkle when a new
thread turns them over again.  Slap me if I'm stating the obvious. :)

73,
Ged.


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Apache::Registry vs Other PerlHandlers (Was: Re: [OT] Re: Shared Module Vars, Missing Object Methods?)

Posted by Garth Webb <ga...@zappos.com>.
On Tue, 2004-02-17 at 12:58, Ged Haywood wrote:
[snip]
> I don't think I can add much to what Perrin has said.  If you're up
> against it because you've walked into a heap of Perl scripts that
> grew like Topsy, you probably don't want to spend the time and take
> the risk of making wholesale changes, especially if the thing is
> doing pretty much what it needs to do.

This is exactly the case.  I'd like to redesign everything, but its not
worth the time and risk right now.

>   But I'd echo Perrin's call
> for a bit of design thinking if you're taking it to the next stage
> of its lifecycle.  There's a lot of experience hiding around here
> somewhere, and nothing provokes a longer thread than a thorny issue.
> Not that I need a lot more mail... :)

Right now I think I might try to convert a select few of our most hit
scripts into handlers to see if some performance can be gained.

> > It seems to me that most people these days are using toolkits
> 
> There are probably good reasons for that.  I think Perrin is the one
> who's done most on comparing and contrasting them, but if you want to
> make a contribution you could do worse than take a few of them out for
> a spin and let us know what you find.  By all means ask what other
> people think about them for your situation first.

Right now we use Text::Tmpl which I'm not crazy about (it leaks memory
and is hard to debug), but it seems to be fastest gun in the west for
the minimal features we use (echo'ing vars, loops and simple
conditionals).  I'd like to move to something more feature rich, but
during high load days our 3 servers really break a sweat as it is. 
Benchmarks showed that the bulk of the time was spent in Text::Tmpl, so
its not our code (though that can always stand improvements).

If anyone knows of any other simple C-based templating systems they use
and like, I'd be interested to hear about it!

-- 

 |- Garth Webb       -|
 |- garth@zappos.com -|

Re: [OT] Re: Shared Module Vars, Missing Object Methods?

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,

On Tue, 17 Feb 2004, Garth Webb wrote:

> (Ged, Sorry for the off-list response)

Apology accepted. :)  Actually for some reason it found its way to
my backup mail exchanger so it sat there a while unnoticed.

But this thread's not OT at all.  Quite the reverse, it addresses an
important issue which we all face from time to time.

I don't think I can add much to what Perrin has said.  If you're up
against it because you've walked into a heap of Perl scripts that
grew like Topsy, you probably don't want to spend the time and take
the risk of making wholesale changes, especially if the thing is
doing pretty much what it needs to do.  But I'd echo Perrin's call
for a bit of design thinking if you're taking it to the next stage
of its lifecycle.  There's a lot of experience hiding around here
somewhere, and nothing provokes a longer thread than a thorny issue.
Not that I need a lot more mail... :)

> It seems to me that most people these days are using toolkits

There are probably good reasons for that.  I think Perrin is the one
who's done most on comparing and contrasting them, but if you want to
make a contribution you could do worse than take a few of them out for
a spin and let us know what you find.  By all means ask what other
people think about them for your situation first.

73,
Ged.


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Re: Shared Module Vars, Missing Object Methods?

Posted by Garth Webb <ga...@zappos.com>.
On Sat, 2004-02-14 at 09:32, Ged Haywood wrote:
> Hi there,
> 
> On Fri, 13 Feb 2004, Garth Webb wrote:
> 
> > So what is a good alternative to Apache::Registry?  My impression was
> > that this is the thing to use unless you want the extra functionality of
> > something like HTML::Mason.
> 
> I'm not sure I understand the question.  Apache::Registry offers a
> means to simulate a CGI environment, so that many existing CGI scripts
> can run unmodified (or with very little modification) under mod_perl,
> giving a substantial performance boost in most cases.  Toolkits like
> HTML::Mason offer very rich sets of features well beyond the scope of
> Apache::Registry and shouldn't really be compared with it.

(Ged, Sorry for the off-list response)

My question was a little confusing.  My comparison between
Apache::Registry and HTML::Mason had to do with both assuming the job of
PerlHandler.  That is, with either one I don't have to make each script
I write into a Perl module and then have separate <Location> entries
mapping each module to a location in my httpd.conf.  With both I can
give a path to my script from the document root and they will take care
of accepting the request and calling my script.

I have around 100 scripts right now, and while I could convert them all
to packages and then set up 100 entries for each in the httpd.conf file,
it seems like that would create a system that is very difficult to
maintain.  For instance, right now I can add a new script and it will be
available to the world whereas with the handler method I would need to
restart Apache so that it can read in the new conf.

I could write a package that would handle all the requests and then call
the appropriate scripts for me, but then I've reinvented
Apache::Registry.

So my question is, what do you think is the better alternative to
Apache::Registry?  If its bad enough that someone like me might have
written a replacement, where is it?  Do people really have conf files
with 100's of <Location> directives?  It seems to me that most people
these days are using toolkits which take care of this URL location to
script location automatically, (thus my original question).

> >  I read:
> > 
> > http://perl.apache.org/docs/1.0/guide/performance.html#Apache__Registry_PerlHandler_vs__Custom_PerlHandler
> > 
> > which shows Apache::Registry is slightly slower (but not by much) than
> > writing a custom Handler.  In my case I have 100's of scripts I'd have
> > to write custom handlers for which seems like a maintenance nightmare. 
> 
> The advice I gave about handlers was to someone starting from scratch
> for whom performance clearly isn't the issue.  I wouldn't have given
> that advice to someone who wants to run hundreds of existing CGI
> scripts with minimal maintenance issues.  I'd probably say now could
> be a good time to look at the 'strict' pragma and the '-w' switch.
> 
> > Has someone reinvented Apache::Registry in a way that isn't a horrible hack?
> 
> Not as far as I'm aware. :)
> 
> Ged.
-- 

 |- Garth Webb       -|
 |- garth@zappos.com -|

Re: [OT] Re: Shared Module Vars, Missing Object Methods?

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,

On Fri, 13 Feb 2004, Garth Webb wrote:

> So what is a good alternative to Apache::Registry?  My impression was
> that this is the thing to use unless you want the extra functionality of
> something like HTML::Mason.

I'm not sure I understand the question.  Apache::Registry offers a
means to simulate a CGI environment, so that many existing CGI scripts
can run unmodified (or with very little modification) under mod_perl,
giving a substantial performance boost in most cases.  Toolkits like
HTML::Mason offer very rich sets of features well beyond the scope of
Apache::Registry and shouldn't really be compared with it.

>  I read:
> 
> http://perl.apache.org/docs/1.0/guide/performance.html#Apache__Registry_PerlHandler_vs__Custom_PerlHandler
> 
> which shows Apache::Registry is slightly slower (but not by much) than
> writing a custom Handler.  In my case I have 100's of scripts I'd have
> to write custom handlers for which seems like a maintenance nightmare. 

The advice I gave about handlers was to someone starting from scratch
for whom performance clearly isn't the issue.  I wouldn't have given
that advice to someone who wants to run hundreds of existing CGI
scripts with minimal maintenance issues.  I'd probably say now could
be a good time to look at the 'strict' pragma and the '-w' switch.

> Has someone reinvented Apache::Registry in a way that isn't a horrible hack?

Not as far as I'm aware. :)

Ged.



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html