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

on

  • 15,738 views

 

Statistics

Views

Total Views
15,738
Views on SlideShare
15,533
Embed Views
205

Actions

Likes
3
Downloads
29
Comments
0

6 Embeds 205

http://share.ez.no 161
http://lanyrd.com 24
http://www.kaliop.fr 12
http://www.kaliop.co.uk 3
http://confluence.kaliop.net 3
http://www.kaliop.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    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 Presentation Transcript

    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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 34000 Montpellier 04 99 13 68 60 23/10/2012 eZ UnConference. Oct 2012 HOW TO BUILD THE PERFECT PAGELAYOUT17 KALIOP.COM
    • 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( - , 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • 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
    • CONCLUSIONConclusion Need cache-blocks only for css & js embedding, main menu, right column, footer... and never need an URI key 32
    • 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