Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is Mod_Perl? 2

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Ok, I have googled , and gone to the mod_perl site.

But all it says is it harnesses the power of Apache & Perl.

so does that mean if you are running apache with perl installed you are running Mod_Perl?

If not , then what makes it mod_perl, and what's the difference between programming in perl and programming in Mod_Perl?

Cheers,

1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
The key description is the following

"mod_perl gives you a persistent Perl interpreter embedded in your web server. This lets you avoid the overhead of starting an external interpreter and avoids the penalty of Perl start-up time, giving you super-fast dynamic content."

mod_perl is an interface layer to apache that gives you more control of the guts of the web server. It also is persistent, so any applications using mod_perl are always running and therefore have no startup time when serving requests.

The one flaw to this approach is that your webservers can become very huge, so it can become necessary to have separate webservers for serving static and dynamic content when you scale.

All the perl boys I meet up with lately are advising a move to PSGI, but my projects still run on mod_perl.

- Miller
 
hmm, that's an odd concept to me , 'always running', I write standard perl , you run a script at the time you need to to do some processing.

I don't have a script I want to be continually running?

That certainly throws a curve ball at the CGI TimeOut parameter!

I guess it's safe to say if you know perl, that doesn't mean you know Mod_Perl!

Is the perl interpreter that slow? I've never had a problem with bad response times from my perl apps?



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Yes, it can make a huge difference to not have the startup time required of standard CGI scripts. There are other ways to have persistent perl code these days, but mod_perl as the first such method. It provided a means to have scripts run literally 100 times as fast.

This is especially important when running ajax applications where each page might have 10 or more subrequests to be served.

Anyway, if you haven't felt the need for it, then more power to ya. But it does provide a means for a significant performance increase.

- Miller
 
Well it might be something I would consider if needs arise, but as my day job is windows based with ActiveState Perl, it's not something I can consider.

My hobby sites run on Apache & Perl, but it's not dedicated hosting, so I can't play with it installing such stuff, plus my web apps aren't that resource hungry to require it.

It's just i got a job spec sent to me and they wanted Mod_Perl, so wondrered what it was and how different to standard perl it was.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Hi

1DMF said:
hmm, that's an odd concept to me , 'always running', I write standard perl , you run a script at the time you need to to do some processing.
That would be really odd. But not the script is running always, just the interpreter. Beside that, mod_perl also caches the bytecodes, so unmodified scripts re not recompiled before each run.

Think to it like using [tt]perl[/tt] in interactive mode as a simple calculator :
[ul]
[li]Start [tt]perl -de 42[/tt][/li]
[li]At the debug prompt you enter the expression to evaluate, like [tt]p 1+2[/tt][/li]
[li]Then you not press [tt]q[/tt] to exit, but leave it open[/li]
[li]An hour later you need something else to calculate - you not start another [tt]perl[/tt] instance, just switch terminal to the already running one and enter the expression to evaluate == you spared the time of starting the interpreter[/li]
[li]Another hour later you need to recalculate the same expression - again you switch to the already running [tt]perl[/tt] instance, press the up-arrow key to get to the previous expression and execute it again == you spared the time of entering the expression[/li]
[/ul]
Wikipedia said:
Large Perl programs start more slowly than similar programs in compiled languages because perl has to compile the source every time it runs.
( Taken from Perl | Comparative performance. )
Perl.com said:
At least as important is code caching: the modules and scripts are loaded and compiled only once, when the server is first started.
( Taken from Why mod_perl? | Why Is mod_perl So Popular?. )

Another minor property of mod_perl is that is the interpreter is invoked based on the MIME type ( which usually is set based on the file extension or the path ). This means :
[ul]
[li]The scripts not need to be opened one more time before running them, just to find out from the shebang which interpreter should handle them.[/li]
[li]The shebang not has to be edited when porting the scripts between systems which have the interpreter installed in different directories.[/li]
[/ul]
Regarding the programming differences, as far as I know there are none. The differences are in configuration possibilities. But I may be wrong in this one.


Feherke.
 
Hi

Feherke said:
1DMF said:
hmm, that's an odd concept to me , 'always running', I write standard perl , you run a script at the time you need to to do some processing.
That would be really odd.
Thinking again, that was quite bad wording. The idea is odd only in case of regular CGI scripts.


The "always running" Perl ( or other ) script which continuously serves CGI request is not a new idea. The old Xitami web server was able to dispatch CGI requests to so called LRWP ( Long Running Web Process ) applications. The LRWP had another big advantage over the mod_perl : loading configuration from file, connecting to database, opening log file and similar operations were not executed before serving each request, only once on LRWP startup. However such LRWP was closer to a web application server, than to a CGI script.

One more sidenote : there are also mod_python and mod_ruby modules and PHP actually comes with such module by default. So mod_perl is not so special case.


Feherke.
 
gotcha thanks for the detailed reply, much appreciated.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top