Top Banner
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
49
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Caching Patterns

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

Page 2: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 2

Daniel Rezny senior technology architect [email protected] @danielrezny

Tomi Vanek senior software architect [email protected] http://tomi.vanek.sk

Page 3: Caching Patterns

3

Data Everything what is DIGITAL is DATA.

Page 4: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 4

Data = Identity & Content

Time

Vo

lum

e

Identity

Individual

Collective

Content

Page 5: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 5

Data = Identity & Content

Time

Vo

lum

e

Identity

Individual

Collective

Page 6: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 6

Page 7: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 7

Good scalability

Transparency

Easy to maintain

Reduced load on source

Fast recovery after failover

Page 8: Caching Patterns

8

Cache Patterns

Read Through Cache

Page 9: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 9

Read Through

Source Cache Client 1

Cache Client 2

Page 10: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 10

Client 1

Client 2

Source

Read Through

Cache

Cache

Page 11: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 11

Client 1

Client 2

Source

Read Through

Cache

Cache

Page 12: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 12

Client 1

Client 2

Source

Read Through

Cache

Cache

Page 13: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 13

Client 1

Client 2

Source

Read Through

Cache

Cache

Page 14: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 14

Client 1

Client 2

Source

Read Through

Cache

Cache

Page 15: Caching Patterns

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

Page 16: Caching Patterns

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

Page 17: Caching Patterns

17

Cache Patterns

Write Through / Write behind

Page 18: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 18

Cache

Cache

Write Through / Write behind

Client 1

Client 2

Destination

Page 19: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 19

Client 1

Client 2

Destination

Write Through / Write behind

Cache

Cache

Page 20: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 20

Client 1

Client 2

Destination

Write Through / Write behind

Cache

Cache

Page 21: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 21

Client 1

Client 2

Destination

Write Through / Write behind

Cache

Cache

Page 22: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 22

• 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

Page 23: Caching Patterns

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

Page 24: Caching Patterns

24

Cache Patterns

Pre-Fetch / Pre-Caching

Page 25: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 25

Trigger

Cache

Pre-Fetch / Pre-Caching

Client Source

Page 26: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 26

Trigger

Cache

Pre-Fetch / Pre-Caching

Client

Source

Page 27: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 27

Trigger

Cache

Pre-Fetch / Pre-Caching

Client

Source

Page 28: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 28

Trigger

Cache

Pre-Fetch / Pre-Caching

Client

Source

Page 29: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 29

Trigger

Cache

Pre-Fetch / Pre-Caching

Client

Source

Page 30: Caching Patterns

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

Page 31: Caching Patterns

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

Page 32: Caching Patterns

32

Cache Patterns

Side Cache

Page 33: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 33

Cache

Side Cache

Source Client Consumer

Page 34: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 34

Cache

Side Cache

Source Client Consumer

Page 35: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 35

Cache

Side Cache

Source Client Consumer

Page 36: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 36

Cache

Side Cache

Source Client Consumer

Page 37: Caching Patterns

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

Page 38: Caching Patterns

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

Page 39: Caching Patterns

39

Cache Patterns

Publisher / Refresh Ahead

Page 40: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 40

Index

Cache

Publisher / Refresh Ahead

Source

Client Publisher

Page 41: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 41

Index

Cache

Publisher / Refresh Ahead

Source

Client Publisher

Page 42: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 42

Index

Cache

Publisher / Refresh Ahead

Source

Client Publisher

Page 43: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 43

Index

Cache

Publisher / Refresh Ahead

Source

Client Publisher

Page 44: Caching Patterns

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

Page 45: Caching Patterns

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

Page 46: Caching Patterns

46

Data Distribution

Page 47: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 47

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

Page 48: Caching Patterns

Copyright © 2014 Accenture All rights reserved. 48

Performing Application

DATA

Right caching pattern

Application improvements

Page 49: Caching Patterns

49

Daniel Rezny Tomi Vanek