Wednesday, July 14, 2010

More on CakePHP performance related to localization

It's been a while since I posted CakePHP performance related tips here. As a matter of fact, it's been a while since I posted anything here. Last year, I spent a lot of time tuning queries and adding code instruments in our system to troubleshoot performance bottlenecks. Here's more on CakePHP:

  1. Cache all your PO files. CakePHP loads localization strings from file system. It's sloooooow. Use APC to cache your PO files. Hack it in i18n.
  2. Cache fallback logics in localization. CakePHP has a fairly complex structure to determine which language it should use to display for a localized text. It makes multiple file reads and in memory lookups before it can determine a display language from browser's supported language header. Hack it in i10n.
  3. Cache the entire view if you can. If the page is static, you only use CakePHP to do localization, cache the entire page. You need to hack view caching and dispatcher code.
If I have to quantify it, step 3 is the biggest performance gain, 300%+ faster, step 1 is the second on the list, 20% to 50%, step 2 should give you another 10% 30% improvements.

No comments: