Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Question about caching

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


daniel.axtell at snet

Mar 13, 2012, 12:51 PM

Post #1 of 5 (578 views)
Permalink
Question about caching

Hello,

I'm looking at upgrading some legacy code that runs under mod_perl with an eye
towards making it more scalable.

I understand the value of having one light-weight server for static content,
and a reverse proxy back to a heavy-weight Apache with mod_perl, and I
understand I can use something like Varnish or mod_cache to add a caching
layer, but I'm wondering if there is much if any value to caching templates
at the application level.

The apps are mostly dynamic forms based on HTML::Template. H::T has some
caching options but they seem more aimed at CGI users. I could convert to
Template::Toolkit, which as I understand converts to compiled Perl code (which
would presumably mean that mod_perl would leave the template objects in
memory).

So does anybody recommend going down to the application level to cache
templates (either by tinkering with HTML::Template or trying to pre-load TT
objects), or is there more bang for the buck by focusing on the server level?
Or is both the way to go? Not sure where diminishing returns kicks in.

Thanks,
Dan


jlarsen at richweb

Mar 13, 2012, 12:57 PM

Post #2 of 5 (561 views)
Permalink
Re: Question about caching [In reply to]

Getting static assets (js, css, gfx) off your apache children is far more
important than anything else for scaling up to lots of concurrent users
IMHO. We use a pound load balancer to direct static reqs to nginx "cdn"
and all dynamic requests to apache backends.

Once you have that in place tuning the data access layer / SQL, server I/O
subsystem, network stack and OS is next most important.

Caching objects and templates would be maybe 3rd and 4th on the to-do
list but after all the above.

On Tue, 13 Mar 2012, Dan Axtell wrote:

> Hello,
>
> I'm looking at upgrading some legacy code that runs under mod_perl with an eye
> towards making it more scalable.
>
> I understand the value of having one light-weight server for static content,
> and a reverse proxy back to a heavy-weight Apache with mod_perl, and I
> understand I can use something like Varnish or mod_cache to add a caching
> layer, but I'm wondering if there is much if any value to caching templates
> at the application level.
>
> The apps are mostly dynamic forms based on HTML::Template. H::T has some
> caching options but they seem more aimed at CGI users. I could convert to
> Template::Toolkit, which as I understand converts to compiled Perl code (which
> would presumably mean that mod_perl would leave the template objects in
> memory).
>
> So does anybody recommend going down to the application level to cache
> templates (either by tinkering with HTML::Template or trying to pre-load TT
> objects), or is there more bang for the buck by focusing on the server level?
> Or is both the way to go? Not sure where diminishing returns kicks in.
>
> Thanks,
> Dan
>
>


mpeters at plusthree

Mar 13, 2012, 1:33 PM

Post #3 of 5 (558 views)
Permalink
Re: Question about caching [In reply to]

On 03/13/2012 03:51 PM, Dan Axtell wrote:

> The apps are mostly dynamic forms based on HTML::Template. H::T has some
> caching options but they seem more aimed at CGI users. I could convert to
> Template::Toolkit, which as I understand converts to compiled Perl code (which
> would presumably mean that mod_perl would leave the template objects in
> memory).

Why do you think the HTML::Template caching options are geared towards
CGI users? It's actually the opposite. All of the caching modes work
just fine under mod_perl. You just need to pick whether you want normal
cache (per-process memory), shared_cache (shared memory), double_cache
(mix of normal cache and shared_cache) or file_cache (no extra memory
uses the filesystem so slower).

In fact, if you using normal CGI you can only use shared_cache or
file_cache.

--
Michael Peters
Plus Three, LP


perrin at elem

Mar 13, 2012, 2:32 PM

Post #4 of 5 (559 views)
Permalink
Re: Question about caching [In reply to]

On Tue, Mar 13, 2012 at 3:51 PM, Dan Axtell <daniel.axtell [at] snet> wrote:
> I understand the value of having one light-weight server for static content,
> and a reverse proxy back to a heavy-weight Apache with mod_perl, and I
> understand I can use something like Varnish or mod_cache to add a caching
> layer,  but I'm wondering if there is much if any value to caching templates
> at the application level.

Well, it makes your page generation faster.

> The apps are mostly dynamic forms based on HTML::Template.  H::T has some
> caching options but they seem more aimed at CGI users.  I could convert to
> Template::Toolkit, which as I understand converts to compiled Perl code (which
> would presumably mean that mod_perl would leave the template objects in
> memory).

Performance is pretty similar between the two and converting to
Template Toolkit would be a big job, so I'd suggest you stay with
HTML::Template unless there's some other problem you're having with
it.

> So does anybody recommend going down to the application level to cache
> templates (either by tinkering with HTML::Template or trying to pre-load TT
> objects), or is there more bang for the buck by focusing on the server level?
> Or is both the way to go?  Not sure where diminishing returns kicks in.

Turn on the template caching. It's basically free and will speed
things up. Caching at the page level is the ultimate in terms of
speed, but it will only be possible for pages that are not dynamic on
a per-user basis. Template caching helps everywhere.

- Perrin


davehodg at gmail

Mar 13, 2012, 3:14 PM

Post #5 of 5 (553 views)
Permalink
Re: Question about caching [In reply to]

On 13 Mar 2012, at 21:32, Perrin Harkins wrote:

>
> Turn on the template caching. It's basically free and will speed
> things up. Caching at the page level is the ultimate in terms of
> speed, but it will only be possible for pages that are not dynamic on
> a per-user basis. Template caching helps everywhere.

A neat trick is to do the "Welcome back Perrin!" stuff in JS. Then the
HTML is the same. If you can get away with it. This was new to me
quite recently :)

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.