Your SlideShare is downloading. ×
0
222 Rond point Ernest Garnier                                                 Immeuble Arche Jacques Cœur                 ...
AGENDAAGENDA    Context    CACHE-BLOCK concepts & Issues    HOWTO build the perfect pagelayout :      0 SQL query (ho...
222 Rond point Ernest Garnier                                Immeuble Arche Jacques Cœur                                  ...
CONTEXTSometimes…  EZ Publish   produce 30 Gbytes of template-block files  EZ Publish   never stop to increase the numb...
CONTEXT& Sometimes... the end customer ask  Is it an          eZ Publish kernel issue OR a lack of knowledge from   the ...
CONTEXT& most of times... a very huge optimization is possible in a quick time, to avoid all theses issues & crashes esp...
222 Rond point Ernest Garnier                                Immeuble Arche Jacques Cœur                                  ...
CACHE-BLOCKWhat for ?               Template-block       cache = cache                files related to cache-block, also...
CACHE-BLOCK  Main parametersKEY value                 Expiry rules(none)                    (none) → 2 hours             ...
CACHE-BLOCK Most of time, a pagelayout looks like     that (ezdemo exemple) :{cache-block keys=array( $module_result.uri,...
CACHE-BLOCKImpact of common parametersThe « URI key » parameter : stupid but  signifiant simulation{cache-block keys=arra...
CACHE-BLOCKImpact of common parametersThe « URI key » parameter : stupid but signifiant  simulation   So...300 SQL queri...
CACHE-BLOCKEasy to say... but how to avoid ?The « keys » parameter :Please AVOID :{cache-block keys=$uri_string}    1 te...
CACHE-BLOCKWhat is the main motivation for using an URI Key ?  easy for caching values which could be different for each...
CACHE-BLOCKHow eZ stores the template-block cache                                       15
CACHE-BLOCKHow eZ stores the template-block cache                                       16
222 Rond point Ernest Garnier                                 Immeuble Arche Jacques Cœur                                 ...
PERFECT PAGELAYOUTWhich values I have to expose ?                                        18
PERFECT PAGELAYOUTWhich values I have to evaluate ?                                          19
PERFECT PAGELAYOUTIs there an out of the box tool for that ?                                             20
PERFECT PAGELAYOUTHow ezpagedata works ?                                          21
PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Title *}{ezpagedata_set( title, $node.name|concat(  - ,   ezin...
PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* metadata *}{ezpagedata_append( metadata,               hash( d...
PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Breadcrumbs *}{set-block variable=breadcrumbs}      {foreach $...
PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Javascript / CSS inclusion *}{ezscript_require( array( myscrip...
PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Javascript / CSS inclusion *}{ezcss_require( array( style.css,...
PERFECT PAGELAYOUTFULL view exemple : node/view/full.tplpublic static function persistent_cache_keys( $namedParameters ){...
PERFECT PAGELAYOUTIs possible to evaluate the key without a template operator ?  YES : keys=first_set( ezpagedata().pers...
PERFECT PAGELAYOUTAm i done ? NO, use the same logical for the main menu :  FULL     : Set your « current section » CSS ...
PERFECT PAGELAYOUTAm i done ?  Use the same logical for the right colunm, the   footer or whatever which is more easy to...
222 Rond point Ernest Garnier                                 Immeuble Arche Jacques Cœur                                 ...
CONCLUSIONConclusion Need cache-blocks only for css & js  embedding, main menu, right  column, footer... and never need ...
CONCLUSIONConclusion 0 SQL query    (home) / 1 SQL query (others)    never more than 100 template-block files !    sav...
eZ UnConference - Z Publish top-performance through mastery (and extension) of the cache layers
eZ UnConference - Z Publish top-performance through mastery (and extension) of the cache layers
Upcoming SlideShare
Loading in...5
×

eZ UnConference - Z Publish top-performance through mastery (and extension) of the cache layers

68,485

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
68,485
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
32
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "eZ UnConference - Z Publish top-performance through mastery (and extension) of the cache layers"

  1. 1. 222 Rond point Ernest Garnier Immeuble Arche Jacques Cœur 34000 Montpellier 04 99 13 68 60 23/10/2012 eZ UnConference. Oct 2012 EZ PUBLISH TOP-PERFORMANCE THROUGH MASTERY (AND EXTENSION) OF THE CACHE LAYERS Gilles Guirand Gilles Ballini CTO Kaliop lead engineer Kaliop eZ Publish board member @gandbox1 KALIOP.COM
  2. 2. AGENDAAGENDA  Context  CACHE-BLOCK concepts & Issues  HOWTO build the perfect pagelayout :  0 SQL query (home) / 1 SQL query (others)  never more than 100 template-block files !  save millions of SQL queries  save I/O & Gigabytes of storage  … save the eZ Publish reputation 2
  3. 3. 222 Rond point Ernest Garnier Immeuble Arche Jacques Cœur 34000 Montpellier 04 99 13 68 60 23/10/2012 eZ UnConference. Oct 2012 CONTEXT3 KALIOP.COM
  4. 4. CONTEXTSometimes…  EZ Publish produce 30 Gbytes of template-block files  EZ Publish never stop to increase the number of cache files  EZ Publish produce millions of SQL queries per day  EZ Publish crash on cache expiry events (subtree expiry)  EZ Publish crash the hosting (beginning of the war!) … 4
  5. 5. CONTEXT& Sometimes... the end customer ask  Is it an eZ Publish kernel issue OR a lack of knowledge from the developers team ?  Is it sodifficult to manage the eZ Publish cache system ? All crashes seems to be related to that  Because the GAP between eZ4 & eZ5, is it not the time to evaluate new CMS competitors ? 5
  6. 6. CONTEXT& most of times... a very huge optimization is possible in a quick time, to avoid all theses issues & crashes especially with the viewcache & the cache-block settings 6
  7. 7. 222 Rond point Ernest Garnier Immeuble Arche Jacques Cœur 34000 Montpellier 04 99 13 68 60 23/10/2012 eZ UnConference. Oct 2012 CACHE-BLOCK CONCEPTS & ISSUES7 KALIOP.COM
  8. 8. CACHE-BLOCKWhat for ?  Template-block cache = cache files related to cache-block, also called « template cache » ( common mistake with the template compilation )  Template-block cache is an HTML (or other) cache of a template part ( cache-block ← Illustration : Łukasz Serwatkahttp://share.ez.no/learn/ez- publish/ez-publish-performance-optimization-part-3-of-3-practical- cache-and-template-solutions/(page)/2 8
  9. 9. CACHE-BLOCK  Main parametersKEY value Expiry rules(none) (none) → 2 hours expiry=3600Custom value, array (none) → on content updatemodule_result.uri ignore_content_expiry+Others ( users, extra ) subtree_expiry=123 subtree_expiry=/news 9
  10. 10. CACHE-BLOCK Most of time, a pagelayout looks like that (ezdemo exemple) :{cache-block keys=array( $module_result.uri, $basket_is_empty, $current_user.contentobject_id ,$extra_cache_key )}<!-- HEAD / HEADER -->{cache-block keys=array( $module_result.uri, $user_hash, $extra_cache_key )}<!-- TOP MENU -->{/cache-block}{/cache-block}{$module_result.content}{cache-block keys=array( $module_result.uri, $user_hash, $access_type.name, $extra_cache_key )}<!-- FOOTER -->{/cache-block} 10
  11. 11. CACHE-BLOCKImpact of common parametersThe « URI key » parameter : stupid but signifiant simulation{cache-block keys=array( $module_result.uri, $user_hash, $extra_cache_key )}<!-- TOP MENU -->{/cache-block}  A classic Web site, with 1000 nodes, news folder ( year, month archives ), products catalog ( filters ), calendar, forum, 2 siteaccess...  Could generate 10 000 « indexable » several URI ( google bot )  A cache-block ( only 1 URI key ) to cache the global menu, who is generating 300 SQL queries  No « expiry » or « ignore_content_expiry » parameters : so the cache-block expires every 2 hours (or on content publication) 11
  12. 12. CACHE-BLOCKImpact of common parametersThe « URI key » parameter : stupid but signifiant simulation  So...300 SQL queries * 12 expiration per day * 10 000 URI = 36 millions of SQL queries per day...  So... 30 000 template-block files ( 3 cache-block ) 12
  13. 13. CACHE-BLOCKEasy to say... but how to avoid ?The « keys » parameter :Please AVOID :{cache-block keys=$uri_string}  1 template-block file... for each URI !!!{/cache-block}Use instead :{cache-block ignore_content_expiry expiry=86400 keys=$my_custom_limited_range_key}...  Only possible states of your{/cache-block} content inside your block 13
  14. 14. CACHE-BLOCKWhat is the main motivation for using an URI Key ?  easy for caching values which could be different for each URI ( title, metas, ezjscore script & css includes, breadcrumbs, main menu, right column... )  found exemple on ezwebin, ezdemo ( is it not the best code exemples ? )  working fine on my workstation, so move on  not mypriority, because not visible, i have IE6/7/8/9/10 CSS issues to resolve first 14
  15. 15. CACHE-BLOCKHow eZ stores the template-block cache 15
  16. 16. CACHE-BLOCKHow eZ stores the template-block cache 16
  17. 17. 222 Rond point Ernest Garnier Immeuble Arche Jacques Cœur 34000 Montpellier 04 99 13 68 60 23/10/2012 eZ UnConference. Oct 2012 HOW TO BUILD THE PERFECT PAGELAYOUT17 KALIOP.COM
  18. 18. PERFECT PAGELAYOUTWhich values I have to expose ? 18
  19. 19. PERFECT PAGELAYOUTWhich values I have to evaluate ? 19
  20. 20. PERFECT PAGELAYOUTIs there an out of the box tool for that ? 20
  21. 21. PERFECT PAGELAYOUTHow ezpagedata works ? 21
  22. 22. PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Title *}{ezpagedata_set( title, $node.name|concat( - , ezini( SiteSettings, SiteName, site.ini ) ) )}pagelayout.tpl{* Title *}{if is_set( ezpagedata().persistent_variable.title )} <title>{ezpagedata().persistent_variable.title|wash}</title>{else} <title>{ezini( SiteSettings, SiteName, site.ini )}</title>{/if} 22
  23. 23. PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* metadata *}{ezpagedata_append( metadata, hash( description, $my_page_description, ‘keywords, $my_keywords ) )}pagelayout.tpl{* metadata *}{foreach ezpagedata().persistent_variable.metadata as $name =>$content} <meta name="{$name|wash}" content="{$content|wash}" />{/foreach} 23
  24. 24. PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Breadcrumbs *}{set-block variable=breadcrumbs} {foreach $node.path as $subpath}... {/foreach}...{/set-block}{ezpagedata_set( breadcrumbs, $breadcrumbs )}Pagelayout.tpl{if is_set( ezpagedata().persistent_variable.breadcrumbs )} <p>{ezpagedata().persistent_variable.breadcrumbs}</p>{/if} 24
  25. 25. PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Javascript / CSS inclusion *}{ezscript_require( array( myscript1.js, myscript2.js ) )}{ezcss_require( array( style.css ) )}No more ezpagedata() ?No, ezjscore share the same persistent variables array,and use variables names : css_files, js_files 25
  26. 26. PERFECT PAGELAYOUTFULL view exemple : node/view/full.tpl{* Javascript / CSS inclusion *}{ezcss_require( array( style.css, style2.css ) )}pagelayout.tpl{def $css_cache_keys = persistent_cache_keys( ezpagedata(), css_files )} {cache-block keys=$css_cache_keys ignore_content_expiryexpiry=86400} {ezcss_load( array( ezini( StylesheetSettings, FrontendCSSFileList,design.ini ) ) )} {/cache-block}{undef $css_cache_keys} 26
  27. 27. PERFECT PAGELAYOUTFULL view exemple : node/view/full.tplpublic static function persistent_cache_keys( $namedParameters ){ $pageData = $namedParameters[pagedata]; $cacheType = $namedParameters[type]; $keys = $pageData[persistent_variable][$cacheType]; if ( empty( $keys ) ) { $keys = array( nokey ); } $operatorValue = array_unique( $keys ); sort( $operatorValue ); return $operatorValue;} 27
  28. 28. PERFECT PAGELAYOUTIs possible to evaluate the key without a template operator ?  YES : keys=first_set( ezpagedata().persistent_variable.js_files, array(0) )|unique()|asort()  But when a template code is not enough readable, i still prefer to read PHP 28
  29. 29. PERFECT PAGELAYOUTAm i done ? NO, use the same logical for the main menu :  FULL : Set your « current section » CSS value, et set a persistent_variable  Pagelayout : get back your persistent_variable & use it like a cache-block key Use the same logical for the right colunm, the footer or whatever which is more easy to evaluate inside the full view 29
  30. 30. PERFECT PAGELAYOUTAm i done ?  Use the same logical for the right colunm, the footer or whatever which is more easy to evaluate inside the full view 30
  31. 31. 222 Rond point Ernest Garnier Immeuble Arche Jacques Cœur 34000 Montpellier 04 99 13 68 60 23/10/2012 eZ UnConference. Oct 2012 CONCLUSION31 KALIOP.COM
  32. 32. CONCLUSIONConclusion Need cache-blocks only for css & js embedding, main menu, right column, footer... and never need an URI key 32
  33. 33. CONCLUSIONConclusion 0 SQL query (home) / 1 SQL query (others)  never more than 100 template-block files !  save millions of SQL queries ( on expiry )  save I/O & Gigabytes of storage … save the eZ Publish reputation 33
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×