Dynamic page caching for Magnolia 5.4
Transcript of Dynamic page caching for Magnolia 5.4
1
#mconf15 @rah003
Magnolia Conference • Wednesday, June 10, 2015 • Basel, Switzerland, Europe, Earth, Solar System, Milky Way
Dynamic Page Caching in Magnolia 5.4
2
Jan HaderkaRoman Kovařík
#mconf15 @rah003
3
2015 Magnolia 5.4
2014 Magnolia 5.3
#mconf15 @rah003
5
Cache? Just one?
FM TL Cache
Browser Cache
HttpResp Cache
Unsplash
RestReq Cache
RegistriesJR Item Cache
#mconf15 @rah003
Cache is a trade-off between perceived performance of a system, internal resource allocation and currentness of delivered data
6
Do we need more?
Flickr / Kenny Louie
#mconf15 @rah003
7
Cache implementation
Flickr / A Syn
Restructured & improved
#mconf15 @rah003
8
Cache module structure
Flickr / A Syn
#mconf15 @rah003
9
Cache implementation
Flickr / A Syn
Separate config per cache
#mconf15 @rah003
11
Cache implementation
Flickr / A Syn
Site-aware CacheFilter
#mconf15 @rah003
14
Cache implementation
Flickr / A Syn
Cache core, impl and UI are now separate
#mconf15 @rah003
15
Cache module structure
Flickr / A Syn
#mconf15 @rah003
16
Cache implementation
Flickr / A Syn
ehCache 1.5 replaced w/ 2.10
#mconf15 @rah003
17 Flickr / A Syn
#mconf15 @rah003
ehCahe 1.5 ehCahe 2.10
18
new ehCache
Flickr / A Syn
5-10% better performance
#mconf15 @rah003
20
new ehCache
Flickr / A Syn
no more disk persistence
#mconf15 @rah003
21
no disk persistence?
Flickr / A Syn
• cache is for production use • when do you restart prod server?
• on update • on crash
#mconf15 @rah003
22
no disk persistence?
Flickr / A Syn
drop-in replacement w/ persistence is BigMemory
#mconf15 @rah003
23
Cache implementation
Flickr / A Syn
new Memcached impl
#mconf15 @rah003
24
Why Memcached?
Flickr / A Syn
separate servers
#mconf15 @rah003
26
Why Memcached?
Flickr / A Syn
clusterable
#mconf15 @rah003
28
Why Memcached?
Flickr / A Syn
eternal
#mconf15 @rah003
30
Why Memcached?
Flickr / A Syn
shareable
#mconf15 @rah003
32
Why Memcached?
Flickr / A Syn
double performance when serving first request*
#mconf15 @rah003
* measured with two public instances connected to same memcached server
35
Cache implementation
Flickr / A Syn
new Supercache impl
#mconf15 @rah003
36
Why Supercache
Flickr / A Syn
external & persistent
#mconf15 @rah003
37
Why Supercache
Flickr / A Syn
served by load balancer
#mconf15 @rah003
38
Why Supercache
Flickr / A Syn
available for onDemand and sysEleven hosting
#mconf15 @rah003
39
Cache tools
Flickr / A Syn
new Cache browser app
#mconf15 @rah003
43
Cache Browser
Flickr / A Syn
explore your cache
#mconf15 @rah003
45
Cache Browser
Flickr / A Syn
exercise control
#mconf15 @rah003
47
Cache Browser
Flickr / A Syn
one that rules them all
#mconf15 @rah003
49
In summary
Flickr / A Syn
•auto-discovery •using REST •single point of control •implementation agnostic
#mconf15 @rah003
50
Cache Browser
Flickr / A Syn
#mconf15 @rah003
Demo time?
52
What about personalised pages?
Flickr / A Syn
They are now cached too
#mconf15 @rah003
53
How?
Flickr / A Syn
•p13n provides variant info into the cache key •Each variant gets it’s own cache entry
#mconf15 @rah003
54
Can personalised pages share fragments?
Flickr / A Syn
Yes, you need to: • configure such fragment as dynamic • use custom cache key generator
#mconf15 @rah003
55
Why not to share by default?
Flickr / A Syn
• complexity • performance
#mconf15 @rah003
56
Advanced Cache
Flickr / A Syn
Dynamic Page Caching DPC
#mconf15 @rah003
57
Dynamic?
Flickr / A Syn
Isn’t dynamic non-cacheable?
#mconf15 @rah003
58
Dynamic?
Flickr / A Syn
“dynamic pages are composed of fragments of content with
different time-to-live”#mconf15 @rah003
59
So how do you do it?
Flickr / A Syn
Just render the page ;)
#mconf15 @rah003
60 Flickr / A Syn
#mconf15 @rah003
http://my.domain.com/travel
http://my.domain.com/travel/main/0
http://my.domain.com/travel/footer/04
http://my.domain.com/travel/footer/03http://my.domain.com/travel/footer/02
http://my.domain.com/travel/footer/01
61
Magnolia meets SiteMesh
Flickr / A Syn
#mconf15 @rah003
62
Magnolia meets SiteMesh
Flickr / A Syn
#mconf15 @rah003
64
Inject content for components
Flickr / A Syn
#mconf15 @rah003
65
What tags?
Flickr / A Syn
#mconf15 @rah003
<mgnl:injecturi target=“/demo-project/about~mgnlArea=branding~” X-Magnolia-Fragment=“sitemesh=skip, ttl=0" >
66
And those tags,
Flickr / A Syn
they got in, how exactly?
#mconf15 @rah003
67 Flickr / A Syn
#mconf15 @rah003
listener.beforeRender()
listener.afterRender()
68
Tags? Yeah, I did those!
Flickr / A Syn
#mconf15 @rah003
Home address: config:/server/rendering/engine/listeners
70
In summary
Flickr / A Syn
• RenderingListener will inject tags • SiteMeshFilter will replace tags with cached (or rendered entries) of content • SiteMesh lives in the chain before Cache, so it is all transparent to it
#mconf15 @rah003
71
In summary
Flickr / A Syn
• Page can consist of multiple fragments with different TTL • Upon expiration content will be re-rendered • Cache filter will cache whatever requested, fragment or full page
#mconf15 @rah003
72
Remember
Flickr / A Syn
The main goal of DPC is improving performance. This is done by caching
non-dynamic portions of a page
#mconf15 @rah003
73
BEWARE!
Flickr / A Syn
Every dynamic component needs to be requested separately. That means, more
dynamic components = more time to render.
#mconf15 @rah003
74
BEWARE!
Flickr / A Syn
more dynamic components = slower rendering Consider excluding such page from the cache!
#mconf15 @rah003
75
BEWARE!
Flickr / A Syn
Although recursive dynamic fragments are supported, it doesn't make sense to
use this feature unless nested components have different TTL.
#mconf15 @rah003
76
BEWARE!
Flickr / A Syn
Group of dynamic componentslocated next to each other
will be rendered faster in one dynamic area rather than
each separately.#mconf15 @rah003
77
Say it really works,
Flickr / A Syn
but does it actually scale?
#mconf15 @rah003
78
Performance ✔
Flickr / A Syn
#mconf15 @rah003
Page=cached SiteMesh=false
Page=cached SiteMesh=true
Snippets: none
Page=cached SiteMesh=true
Snippets: 1cached
Page=cached SiteMesh=true
Snippets: 1uncached
Page=uncached SiteMesh=false
Page=uncached SiteMesh=true
TTFB 0.00233 0.00311 0.004119 0.04095 0.04864 0.06377Total 0.00275 0.00315 0.004142 0.04143 0.06443 0.06418% TTFB 5 6 8 84 100 131% Total 4 5 6 64 100 100
79
Can same fragment be shared by multiple pages?
Flickr / A Syn
yes, but you need custom cache key/generator (just like p13n)
#mconf15 @rah003
80
#mconf15 @rah003
Thanks!
Questions?
81
Backup
82
NonCacheableEntry
Flickr / A Syn
anti-coagulant for your pipeline
#mconf15 @rah003
PersonalizationAnalytics Commerce CRM
www Mobile Site Newsletter Landing PageApp
Integration/Inbound
Multi-Channel OutboundMulti-Channel Outbound
PersonalizationAnalytics Commerce CRM
www Mobile Site Newsletter Landing PageApp
86 Unsplash / Maja Petric
Integrations
Google Analytics
IBM Digital
Analytics
AWSJelastic
IBM Bluemix
Groovy Spring
LDAP /ADNTLM
AlfrescoCanto
Cumulus
Bright-cove
Share-point Photo-
shop
Magento
Hybris
KonaKart
IBM Smarter
Commerce
Salesforce
SugarCRM
Campaign Monitor
Click-density
Eloqua
Optimizely
Steelhouse Canvas
Atom /RSS
AddThis
FacebookFlickr
Share-This
TwitterApache
Solr
Apache OFBiz
SAP
87
✔
✔
✔
✔
✔