Accenture Caching Patterns and Strategies · Media Partner Organizers Top Media Partner General...
Transcript of Accenture Caching Patterns and Strategies · Media Partner Organizers Top Media Partner General...
Media Partner
Organizers
Top Media Partner
General Partner
Supporters
Daniel Rezny, Tomi VanekAccentureDigital in Space & Time
Caching Patterns and StrategiesOctober 17, 2014
Copyright © 2014 Accenture All rights reserved. 2
Daniel Reznysenior technology architect
[email protected]@danielrezny
Tomi Vaneksenior software architect
[email protected]://tomi.vanek.sk
www.sli.do/openslava
or just raise your hand!
To ask questions
3
4
DataEverything what is DIGITAL is DATA.
Copyright © 2014 Accenture All rights reserved. 5
Data = Identity & Content
Time
Vo
lum
e
Identity
Individual
Collective
Content
Copyright © 2014 Accenture All rights reserved. 6
Data = Identity & Content
Time
Vo
lum
e
Identity
Individual
Collective
Copyright © 2014 Accenture All rights reserved. 7
Copyright © 2014 Accenture All rights reserved. 8
Good scalability
Transparency
Easy to maintain
Reduced load on source
Fast recovery after failover
9
Cache Patterns
Read Through Cache
Copyright © 2014 Accenture All rights reserved. 10
Read Through
SourceCacheClient 1
CacheClient 2
Copyright © 2014 Accenture All rights reserved. 11
Client 1
Client 2
Source
Read Through
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 12
Client 1
Client 2
Source
Read Through
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 13
Client 1
Client 2
Source
Read Through
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 14
Client 1
Client 2
Source
Read Through
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 15
Client 1
Client 2
Source
Read Through
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 16
• Simple, transparent• Scalable• Faster response time by repeating requests• Decreases load to data source
• Read only• Only for repeating requests• For data with rare changes• Requests for unique data hit data source
Copyright © 2014 Accenture All rights reserved. 17
Read Through usage examples
Content Delivery Network (CDN)
HTTP reverse proxy
Browser proxy
API management tools
Reusable data closer to consumption
18
Cache Patterns
Write Through / Write behind
Copyright © 2014 Accenture All rights reserved. 19
Cache
Cache
Write Through / Write behind
Client 1
Client 2
Destination
Copyright © 2014 Accenture All rights reserved. 20
Client 1
Client 2
Destination
Write Through / Write behind
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 21
Client 1
Client 2
Destination
Write Through / Write behind
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 22
Client 1
Client 2
Destination
Write Through / Write behind
Cache
Cache
Copyright © 2014 Accenture All rights reserved. 23
• Transparently hide destination systems• The only application’s source of data• Limit amount of requests to the source • Avoid cache misses• Database unknown for application• Split of responsibilities
• Does not improve writes speed• Possible data inconsistences• Cache transaction finish before database’
starts
Copyright © 2014 Accenture All rights reserved. 24
Write Through usage examples
Additional application layer
API management tools
Content delivery network
Lot of writes and reads
25
Cache Patterns
Pre-Fetch / Pre-Caching
Copyright © 2014 Accenture All rights reserved. 26
Trigger
Cache
Pre-Fetch / Pre-Caching
Client Source
Copyright © 2014 Accenture All rights reserved. 27
Trigger
Cache
Pre-Fetch / Pre-Caching
Client
Source
Copyright © 2014 Accenture All rights reserved. 28
Trigger
Cache
Pre-Fetch / Pre-Caching
Client
Source
Copyright © 2014 Accenture All rights reserved. 29
Trigger
Cache
Pre-Fetch / Pre-Caching
Client
Source
Copyright © 2014 Accenture All rights reserved. 30
Trigger
Cache
Pre-Fetch / Pre-Caching
Client
Source
Copyright © 2014 Accenture All rights reserved. 31
• Fast read of non-repetitive data• Prepare data for usage in advance• Transparent work "behind the scene"
• Increased load on resources (data source, network, cache size)
• Redundant data in cache• Complex trigger logic
Copyright © 2014 Accenture All rights reserved. 32
Pre-Fetch usage examples
Master-detail pattern (search)
Asynchronous page refresh
Database pre-fetch
Guided navigation
Preload of web assets
Automated and manual pre-fetching
33
Cache Patterns
Side Cache
Copyright © 2014 Accenture All rights reserved. 34
Cache
Side Cache
SourceClientConsumer
Copyright © 2014 Accenture All rights reserved. 35
Cache
Side Cache
SourceClientConsumer
Copyright © 2014 Accenture All rights reserved. 36
Cache
Side Cache
SourceClientConsumer
Copyright © 2014 Accenture All rights reserved. 37
Cache
Side Cache
SourceClientConsumer
Copyright © 2014 Accenture All rights reserved. 38
• Lower load to the data source• Read Through emulation possible• Effectively loads data on demand • Data lifecycle management possible• Supporting pre-caching might be used
• Not fully transparent• Additional hops to the cache • Not good for static data
Copyright © 2014 Accenture All rights reserved. 39
Side cache usage examples
When dynamic data used
Resource demand is not predictable
Local storage in browser
Large amount of data
40
Cache Patterns
Publisher / Refresh Ahead
Copyright © 2014 Accenture All rights reserved. 41
Index
Cache
Publisher / Refresh Ahead
Source
Client Publisher
Copyright © 2014 Accenture All rights reserved. 42
Index
Cache
Publisher / Refresh Ahead
Source
Client Publisher
Copyright © 2014 Accenture All rights reserved. 43
Index
Cache
Publisher / Refresh Ahead
Source
Client Publisher
Copyright © 2014 Accenture All rights reserved. 44
Index
Cache
Publisher / Refresh Ahead
Source
Client Publisher
Copyright © 2014 Accenture All rights reserved. 45
• Very high scalability• Controlled “freshness” of data• Distributed• Data source does not limit the scaling of the
application
• Read Only• Does not reflect frequent changes• Snapshot of data in history
Copyright © 2014 Accenture All rights reserved. 46
Publisher usage examples
Good for static data
Optimized images for responsive design
Reports, graphs
Documents in PDF / EPub / Mobi
Stock amount in Eshop
47
Data Distribution
Copyright © 2014 Accenture All rights reserved. 48
CDN
• Static files and images
• Websites
Front-end
• HTTP requests and session data
• User’s data
Application logic
• Short-term code results
• External calls and sessions
Integration
• Request to external systems
• Responses from requests
Database layer
• SQL queries and parameters
• Connection strings and configurations
CDN
Frontend
Application Logic
Integration
Database Layer
Copyright © 2014 Accenture All rights reserved. 49
PerformingApplication
DATA
Right caching pattern
Application improvements
www.sli.do/openslava
Questions, Answers & Ratings
50
51
Daniel ReznyTomi Vanek