View
165
Download
0
Tags:
Embed Size (px)
Media Partner
Organizers
Top Media Partner
General Partner
Supporters
Daniel Rezny, Tomi Vanek Accenture Digital in Space & Time
Caching Patterns and Strategies October 17, 2014
Copyright 2014 Accenture All rights reserved. 2
Daniel Rezny senior technology architect daniel.rezny@accenture.com @danielrezny
Tomi Vanek senior software architect tomas.vanek@accenture.com http://tomi.vanek.sk
3
Data Everything what is DIGITAL is DATA.
Copyright 2014 Accenture All rights reserved. 4
Data = Identity & Content
Time
Vo
lum
e
Identity
Individual
Collective
Content
Copyright 2014 Accenture All rights reserved. 5
Data = Identity & Content
Time
Vo
lum
e
Identity
Individual
Collective
Copyright 2014 Accenture All rights reserved. 6
Copyright 2014 Accenture All rights reserved. 7
Good scalability
Transparency
Easy to maintain
Reduced load on source
Fast recovery after failover
8
Cache Patterns
Read Through Cache
Copyright 2014 Accenture All rights reserved. 9
Read Through
Source Cache Client 1
Cache Client 2
Copyright 2014 Accenture All rights reserved. 10
Client 1
Client 2
Source
Read Through
Cache
Cache
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
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. 16
Read Through usage examples
Content Delivery Network (CDN)
HTTP reverse proxy
Browser proxy
API management tools
Reusable data closer to consumption
17
Cache Patterns
Write Through / Write behind
Copyright 2014 Accenture All rights reserved. 18
Cache
Cache
Write Through / Write behind
Client 1
Client 2
Destination
Copyright 2014 Accenture All rights reserved. 19
Client 1
Client 2
Destination
Write Through / Write behind
Cache
Cache
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
Transparently hide destination systems The only applications 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. 23
Write Through usage examples
Additional application layer
API management tools
Content delivery network
Lot of writes and reads
24
Cache Patterns
Pre-Fetch / Pre-Caching
Copyright 2014 Accenture All rights reserved. 25
Trigger
Cache
Pre-Fetch / Pre-Caching
Client Source
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
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. 31
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
32
Cache Patterns
Side Cache
Copyright 2014 Accenture All rights reserved. 33
Cache
Side Cache
Source Client Consumer
Copyright 2014 Accenture All rights reserved. 34
Cache
Side Cache
Source Client Consumer
Copyright 2014 Accenture All rights reserved. 35
Cache
Side Cache
Source Client Consumer
Copyright 2014 Accenture All rights reserved. 36
Cache
Side Cache
Source Client Consumer
Copyright 2014 Accenture All rights reserved. 37
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. 38
Side cache usage examples
When dynamic data used
Resource demand is not predictable
Local storage in browser
Large amount of data
39
Cache Patterns
Publisher / Refresh Ahead
Copyright 2014 Accenture All rights reserved. 40
Index
Cache
Publisher / Refresh Ahead
Source
Client Publisher
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
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. 45
Publisher usage examples
Good for static data
Optimized images for responsive design
Reports, graphs
Documents in PDF / EPub / Mobi
Stock amount in Eshop
46
Data Distribution
Copyright 2014 Accenture All rights reserved. 47
CDN
Static files and images
Websites
Front-end
HTTP requests and session data
Users 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. 48
Performing Application
DATA
Right caching pattern
Application improvements
49
Daniel Rezny Tomi Vanek