Abhishek Mishra
Abhishek Mishra

Reputation: 5040

Has anyone made actual gains by using a faster templating engine in GAE/ App Engine?

I'm very tempted by pyTenjin's performance - http://www.kuwata-lab.com/tenjin/ It definitely beats the shit out of other templating engines - mako, jinja2, etc. But at the same time comes with the cost of learning a bit ugly templating system. Personally I love jinja2 / django style templates.

I like the idea that pyTenjin can bring down CPU usage to some extent - http://www.kuwata-lab.com/tenjin/pytenjin-faq.html#faq-google-appengine

I'm considering pyTenjin to either a) build views to be served in iframes on my customers' websites or b) to use it to generate dynamic javascripts based on configurations

Performance seems to be a good plus point. On the minus, we have a little bit of time to learn pyTenjin and a bit of ugliness compromise. I could stick with jinja2 and divert focus on speed of development rather than that of ops/s

But I wonder if the CPU usage reduction is significant at all. With not many heavily loaded app engine examples around me, I have to ask, has anyone experienced any gains in terms of CPU usage by changing their templating system so far?

Upvotes: 2

Views: 254

Answers (1)

moraes
moraes

Reputation: 13629

Mako is pretty fast. But Jinja2 can be as fast if you use compiled templates. They are compiled to Python code and there's a loader to use them.

I recommend you to make a conditional to use compiled templates in production and normal rendering while developing. Also, set auto_reload=False when instantiating the Environment in production, because your templates never change in production. And of course, cache rendered output when you can.

Unless you're rendering huge templates, I don't see why you should spend your time moving to a different template system than the traditional Mako/Django/Jinja2.

Upvotes: 1

Related Questions