On Sun, Sep 09, 2007 at 12:28:58PM -0400, Peter Hartzler wrote: > I'm hoping to reduce the overall memory footprint without losing the > benefits of caching. (Lazy AND greedy!) Tmpl->Perl parsing overhead is > less of an issue for us, for the reason you mention. > > Our site currently has around 200 templates. What I *think* I'm seeing > is memory consumption where each apache instance (child w/ mod_perl) > keeps its own cache. The next step from there is the idea of > centralized caching.
I see. When you mentioned memcached that made me think you wanted to share across servers. I don't see memcached helping here, but I might be wrong. It's not like you can use memcached as extra memory for your process. The templates have to be in memory -- they are just anonymous perl subs, after all. Loading them into the parent process before forking might help, but I'm not sure how to do that since you don't really know what templates are going to be loaded until run-time. I have also wondered about very text-heavy templates. It does seem like a waste to have all that text in multiple process's memory space. But, when I adding up all the text it wasn't really that much in bytes. The common approach, of course, is to use a reverse proxy so the mod_perl/TT server doesn't need so many processes running. I wonder if one could take that an extra step and have a separate server that is just a template engine -- after all TT is kind of a service, pass in a stash and return text. I'd probably throw memory at the problem, instead, though. > It's entirely possible that other approaches might be better. I'm > suspicious of my proposal if for no other reason than the leading '_' in > '_load_compiled()' So, your questions, and the testing/verification of > any answers, are quite valuable, thanks! I'm not sure how significant the underscore is. And placing the parsed template cache in memcached doesn't seem like it would be helpful. I think using the local disk to store the "compiled" templates would be better then fetching them over the network. And again, fetching from that store should only happen when first loading that template in each process. After that the template should be cached in that LOOKUP hash. -- Bill Moseley [EMAIL PROTECTED] _______________________________________________ templates mailing list [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates
