You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dan Axtell <da...@snet.net> on 2012/03/13 20:51:23 UTC
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
Re: Question about caching
Posted by Michael Peters <mp...@plusthree.com>.
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
Re: Question about caching
Posted by Dave Hodgkinson <da...@gmail.com>.
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 :)
Re: Question about caching
Posted by Perrin Harkins <pe...@elem.com>.
On Tue, Mar 13, 2012 at 3:51 PM, Dan Axtell <da...@snet.net> 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
Re: Question about caching
Posted by "C. Jon Larsen" <jl...@richweb.com>.
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
>
>