You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jochen Lillich <jl...@teamlinux.de> on 2002/10/03 16:50:05 UTC
Dynamlcally loading modules at run-time
Hi,
I'm writing my first mod_perl handler. I'd like to make the handler some
kind of dispatcher that dynamically loads certain modules depending on
the URI called:
/foo/index => require foo; $result = foo::index();
/foo/other => require foo; $result = foo::other();
/bar/index => require bar; $result = bar::index();
I'd like to ask for your advice there. Is this a clever way to go in
the first place? And how would i best code this concept? Or is there a
better way to reach a modular structure in a big web application?
Best regards,
Jochen
Re: Dynamlcally loading modules at run-time
Posted by Jason Galea <j...@eightdegrees.com.au>.
Hi Jochen,
I'd recommend having a read of this
http://perl.apache.org/docs/1.0/guide/performance.html#Sharing_Memory
Not sure how much it applies to your situation, but basically, unless the
different modules are very large and rarely used you really want to load them
all at server startup. That way your server processes will be sharing the
majority of your code and memory use will be optimised increasing the number
of server processes you'll be able to run. Loading more modules after startup
will increase the size of each process independantly, increasing your overall
memory use.
cheers,
J
Jochen Lillich wrote:
> Hi,
>
> I'm writing my first mod_perl handler. I'd like to make the handler some
> kind of dispatcher that dynamically loads certain modules depending on
> the URI called:
>
> /foo/index => require foo; $result = foo::index();
> /foo/other => require foo; $result = foo::other();
> /bar/index => require bar; $result = bar::index();
>
> I'd like to ask for your advice there. Is this a clever way to go in
> the first place? And how would i best code this concept? Or is there a
> better way to reach a modular structure in a big web application?
>
> Best regards,
>
> Jochen
>
> .
>
Re: Dynamlcally loading modules at run-time
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Jochen Lillich wrote:
> Hi,
>
> I'm writing my first mod_perl handler. I'd like to make the handler some
> kind of dispatcher that dynamically loads certain modules depending on
> the URI called:
>
> /foo/index => require foo; $result = foo::index();
> /foo/other => require foo; $result = foo::other();
> /bar/index => require bar; $result = bar::index();
look into Apache::Dispatch. I haven't touched the code in a while,
but it does what you're seeking.
>
> I'd like to ask for your advice there. Is this a clever way to go in
> the first place? And how would i best code this concept? Or is there a
> better way to reach a modular structure in a big web application?
probably :) try looking at things like Mason, Embperl, Template
Toolkit, Apache::ASP...
--Geoff