Presentation is loading The Latency Problem 100 ms Average : 9,3s - - PowerPoint PPT Presentation

presentation is loading the latency problem
SMART_READER_LITE
LIVE PREVIEW

Presentation is loading The Latency Problem 100 ms Average : 9,3s - - PowerPoint PPT Presentation

The Cache Sketch: Revisiting Expiration-based Caching in the Age of Cloud Data Management Felix Gessert, Michael Schaarschmidt, Wolfram Wingerath, Steffen Friedrich, Norbert Ritter gessert@informatik.uni-hamburg.de Presentation is loading


slide-1
SLIDE 1

Felix Gessert, Michael Schaarschmidt, Wolfram Wingerath, Steffen Friedrich, Norbert Ritter

gessert@informatik.uni-hamburg.de

The Cache Sketch: Revisiting

Expiration-based Caching in the Age of Cloud Data Management

slide-2
SLIDE 2

Presentation is loading

slide-3
SLIDE 3

Average: 9,3s

The Latency Problem

Loading…

  • 1% Revenue

100 ms

slide-4
SLIDE 4

The Latency Problem

  • 1% Revenue
  • 9% Visitors

400 ms

slide-5
SLIDE 5

Average: 9,3s

The Latency Problem

Loading…

  • 1% Revenue
  • 9% Visitors

500 ms

  • 20% Traffic
slide-6
SLIDE 6

Average: 9,3s

The Latency Problem

Loading…

  • 1% Revenue
  • 9% Visitors
  • 20% Traffic

1s

  • 7% Conversions
slide-7
SLIDE 7

If perceived speed is such an import factor

...what causes slow page load times?

slide-8
SLIDE 8

State of

  • f the art

Two bottlenecks: : la latency und processing

High Latency Processing Time

slide-9
SLIDE 9

Network Latency

Th The underlying problem of

  • f hig

igh page lo load tim times

  • I. Grigorik, High performance browser networking.

O’Reilly Media, 2013.

slide-10
SLIDE 10

The lo low-latency vis ision

Data is is served by by ubiquitous web-caches

Low Latency Less Processing

slide-11
SLIDE 11

Expiration-based Every object has a defined Time-To-Live (TTL) Revalidations Allow clients and caches to check freshness at the server

The web‘s cachin ing model

Staleness as as a a consequence of

  • f scalability
slide-12
SLIDE 12

Expiration-based Every object has a defined Time-To-Live (TTL) Revalidations Allow clients and caches to check freshness at the server Stale Da Data

The web‘s cachin ing model

Staleness as as a a consequence of

  • f scalability
slide-13
SLIDE 13

Expiration-based Every object has a defined Time-To-Live (TTL) Revalidations Allow clients and caches to check freshness at the server Stale Da Data

The web‘s cachin ing model

Staleness as as a a consequence of

  • f scalability

Research Question:

Can database services leverage the web caching infrastructure for low latency with rich consistency guarantees?

slide-14
SLIDE 14

Client Expi pira ration

  • n-

based Caches Invalida dation

  • n-

based Caches

Request Path

Server/DB

Cache Hits

Browser Caches, Forward Proxies, ISP Caches Content Delivery Networks, Reverse Proxies

Expiration-based Caches:

 An object x is considered

fresh for TTLx seconds

 The server assigns TTLs

for each object In Invalidation-based Caches:

 Expose object eviction

  • peration to the server

Web Cachin ing Concepts

In Invalidation- and and expiration-based caches

slide-15
SLIDE 15

Client Expi pira ration

  • n-

based Caches Invalida dation

  • n-

based Caches

Request Path

Server/DB

Cache Hits

Browser Caches, Forward Proxies, ISP Caches Content Delivery Networks, Reverse Proxies

at connect Periodic every Δ seconds at transaction begin

2 3 1

Invalidations, Records Needs Invalidation?

4

Needs Revalidation?

The Cache Sketch approach

Le Letting th the clie client handle cache coherence

Staleness ss-Minimization Invalidation-Minimization Client nt Cache he Sketch

10101010

Bloom filter

Serv rver r Cache he Sketch

10201040 10101010

Counting Bloom Filter Non-expired Record Keys Report Expirations and Writes

slide-16
SLIDE 16

The End to to End Path of

  • f Request

Th The Caching Hie ierarchy

Client- (Browser-) Cache Proxy Caches ISP Caches CDN Caches Reverse- Proxy Cache

Miss Hit Miss Miss Miss Miss

Orestes

DB.posts.get(id) JavaScript

Updated by Cache Sketch Updated by the server

slide-17
SLIDE 17

The End to to End Path of

  • f Request

Th The Caching Hie ierarchy

Client- (Browser-) Cache Proxy Caches ISP Caches CDN Caches Reverse- Proxy Cache

Miss Hit Miss Miss Miss Miss

Orestes

GET /db/posts/{id} HTTP

Updated by Cache Sketch Updated by the server

slide-18
SLIDE 18

The End to to End Path of

  • f Request

Th The Caching Hie ierarchy

Client- (Browser-) Cache Proxy Caches ISP Caches CDN Caches Reverse- Proxy Cache

Miss Hit Miss Miss Miss Miss

Orestes

Updated by Cache Sketch Updated by the server

Ca Cache-Hit it: Return Object Ca Cache-Miss or

  • r Revalid

idation: Forward Request

slide-19
SLIDE 19

The End to to End Path of

  • f Request

Th The Caching Hie ierarchy

Client- (Browser-) Cache Proxy Caches ISP Caches CDN Caches Reverse- Proxy Cache

Miss Hit Miss Miss Miss Miss

Orestes

Updated by Cache Sketch Updated by the server

Return record from DB with caching TTL

slide-20
SLIDE 20

The End to to End Path of

  • f Request

Th The Caching Hie ierarchy

Client- (Browser-) Cache Proxy Caches ISP Caches CDN Caches Reverse- Proxy Cache

Miss Hit Miss Miss Miss Miss

Orestes

Updated by Cache Sketch Updated by the server Low Latency Reduced Database Load Flash-Crowd Protection Higher Availability

slide-21
SLIDE 21

 Let ct be the client Cache Sketch generated at time t, containing

the key keyx of every record x that was written before it expired in all caches, i.e. every x for which holds:

The Cli lient Cache Sketch

∃ 𝑠(𝑦, 𝑢𝑠, 𝑈𝑈𝑀), 𝑥 𝑦, 𝑢𝑥 ∶ 𝑢𝑠 + 𝑈𝑈𝑀 > 𝑢 > 𝑢𝑥 > 𝑢𝑠

k hash functions m Bloom filter bits 1 1 1 1 1

h1 hk ... key

find(key)

Cli lient nt Cache he Sketch

Bits = 1 no yes GET request Revalidation

Cache he

Hit Miss

key key

slide-22
SLIDE 22

1 4 2

purge(obj) hashB(oid) hashA(oid)

3 1 1 1 1

Flat(Counting Bloomfilter) hashB(oid) hashA(oid)

Browser Cache CDN 1

 Solution: Cached In

Init itialization

  • Clients load the Cache Sketch at connection
  • Every non-stale cached record can be reused

without degraded consistency

Slo low in initial page lo loads

1

slide-23
SLIDE 23

1 4 2

purge(obj) hashB(oid) hashA(oid)

3 1 1 1 1

Flat(Counting Bloomfilter) hashB(oid) hashA(oid)

Browser Cache CDN 1

 Solution: Cached In

Init itialization

  • Clients load the Cache Sketch at connection
  • Every non-stale cached record can be reused

without degraded consistency

Slo low in initial page lo loads

1

𝑔 ≈ 1 − 𝑓−𝑙𝑜

𝑛 𝑙

𝑙 = ln 2 ⋅ (

𝑜 𝑛)

False-Positive Rate: Hash- Functions: With 20.000 distinct updates and 5% error rate: 11 KByte

slide-24
SLIDE 24

 Solution: Δ-Bounded Staleness

  • Clients refresh the Cache Sketch so its age never exceeds Δ

→ Consistency guarantee: Δ-atomicity

Slo low CRUD performance

Client Expiration- based Caches Invalidation- based Caches Server

Cache Sketch ct Qu Query Cache Sketch fresh records Revalidate record & Refresh Cache Sketch Cache Hits Fresh record & new Cache Sketch

  • time t
  • time t + Δ

2

slide-25
SLIDE 25

Hig igh Abort Rates in in OCC

Cache Cache Cache

REST-Server REST-Server REST-Server DB

Coordinator

Client

Begin Transaction Bloom Filter

1

Reads Writes

2

Writes (Hidden) validation 4

5

Writes (Public) Read all

prevent conflicting validations

 Solution: Conflict-Avoidant Optimistic Transactions

  • Cache Sketch fetched with transaction begin
  • Cac

ached reads → Sh Shorter tr transaction duration → le less ss ab aborts

3

Committed OR aborted + stale objects

Commit: read- & write-set versions

3

slide-26
SLIDE 26

Costly In Invalidations

 Solution: In

Invalidation Min inimization

  • The server Cache Sketch tracks TTLs
  • Invalidation on
  • nly

ly necessary, if there are unexpired records

Server Cache he Sketch

10201040 10101010

Counting Bloom Filter Non-expired Record Keys Report Expirations and Writes Needs Invalidation?

4

slide-27
SLIDE 27

End-to to-End Example

Client Expiration- based Cache Invalidation- based Cache Server Client Cache Sketch Server Cache Sketch

b={x2} t = {(x2, t2), (x3, t3),(x1, t1)} b=

INITIALIZE

c={(x2,t2),(x3,t3)} c={(x1,t1)

b={x2}

CONNECT

bt0={x2}

READ x3 QUERY

x3

RESPONSE

false

GET

x3

RESPONSE

x3

QUERY

x2

RESPONSE

true

READ x2

REVALIDATE

x2

c={(x3,t3)}

RESPONSE

x2,t4

c={(x2,t4),(x3,t3)} c={(x2,t4)}

REPORT READ

x2,t4

b={x2} t = {(x2, t4), (x3, t3),(x1, t1)}

RESPONSE

inv=true

WRITE x1 PUT

x1=v

REPORT WRITE

x1

RESPONSE

  • k

INVALIDATE

x1

b={x1,x2} t = {(x2, t4), (x3, t3),(x1, t1)}

slide-28
SLIDE 28

 Problem: if TTL ≫ time to next write, then it is

contained in Cache Sketch unnecessarily long

 TTL

TL Esti timator: finds „best“ TTL

 Trade-Off:

TTL Estimation

Determining th the best TTL TL

Lo Longer TTL TLs Sh Shorter TTLs

  • Higher cache-hit rates
  • more invalidations
  • less invalidations
  • less stale reads
slide-29
SLIDE 29

Id Idea:

  • 1. Estimate average time to next write 𝐹[𝑈

𝑥] for each record

  • 2. Weight 𝐹[𝑈

𝑥] using the cache miss rate

TTL Estimation

Determining th the best TTL TL

Client Server

Reads Misses λm: Miss Rate λw: Write Rate collect TTL per record λm λw

Caches

Writes ~ Poisson

TTL Estimator

Objective:

  • maximize Cache Hits
  • minimize Purges
  • minimize Stale Reads
  • bound Cache Sketch

false positive rate

Writes ~ Poisson

slide-30
SLIDE 30

 Goal: Analysis of arbitrary caching architectures using

the standard YCSB benchmark

  • Metric

ics to to evaluate: Latency, Throughput, Cache Hits, Stale Reads, Invalidations

YCSB Monte Carlo lo Cachin ing Sim imulator (YMCA)

Pluggable simulated caches, choosable topology

YCSB SB wo workload YMCA Client

Stale Read Detector Cache Miss Detector

Expiration- based Cache Invalidation- based Cache Database Ser erver er

Pluggable latency distributions

purge CRUD CRUD CRUD CRUD

slide-31
SLIDE 31

Results: Sim imulation & real-world

CDN Northern California Client MongoDB Orestes Ireland

Setup:

Page load times with cach ched in initia itialization (YMCA): Average Latency for YCSB Workloads A and B (real):

slide-32
SLIDE 32

Results: Sim imulation & real-world

CDN Northern California Client MongoDB Orestes Ireland

Setup:

Page load times with cach ched in initia itialization (YMCA): Average Throughput for YCSB Workloads A and B (real):

slide-33
SLIDE 33

 Goal: Efficient Generation of Cache Sketch and

Invalidation Minimization

 Cou

  • untin

ing Bloo loom Filt Filter and key → expir iration mapping

The Server Cache Sketch

Scalable Im Implementation

https://github.com/Baqend/Orestes-Bloomfilter

Add keyx if x unexpired

Cache Sketch for Table A … B … C

Get Cache Sketch: Union

(Bitwise OR)

slide-34
SLIDE 34

The Big ig Pic icture

Im Implementation in in ORESTES

Internet Cache Sketch Reverse-Proxy Caches Orestes Servers Desktop Mobile Tablet

Content-Delivery- Network

 Cache Sketch is part of ORESTES, a database-

independent Backend-as-a-Service

slide-35
SLIDE 35

The Big ig Pic icture

Im Implementation in in ORESTES

Internet Cache Sketch Reverse-Proxy Caches Orestes Servers Desktop Mobile Tablet

Content-Delivery- Network

Polyglot Storage

slide-36
SLIDE 36

The Big ig Pic icture

Im Implementation in in ORESTES

Internet Cache Sketch Reverse-Proxy Caches Orestes Servers Desktop Mobile Tablet

Content-Delivery- Network

Database-as-a-Service Middleware: Caching, Transactions, Schemas, Authorization, Multi-Tenancy

slide-37
SLIDE 37

The Big ig Pic icture

Im Implementation in in ORESTES

Internet Cache Sketch Reverse-Proxy Caches Orestes Servers Desktop Mobile Tablet

Content-Delivery- Network

Standard HTTP Caching

slide-38
SLIDE 38

The Big ig Pic icture

Im Implementation in in ORESTES

Internet Cache Sketch Reverse-Proxy Caches Orestes Servers Desktop Mobile Tablet

Content-Delivery- Network

Unified REST API

slide-39
SLIDE 39

Future Work

Query ry-Result-Caching

Cached Query

ORESTES

Create, Update, Delete

Pub-Sub

  • peration &

after-image

Ca Caches Pub-Sub Ca Cache Sketch & In Invalid idator

invalidate Cache Sketch

  • f queries

Changed queries

Stream-Processing: Which query result sets changed? Decision Model: When is it better to cache lists of ids vs. full results and for which TTL – or not at all?

slide-40
SLIDE 40

Team: Felix Gessert, Florian Bücklers, Hannes Kuhlmann, Malte Lauenroth, Michael Schaarschmidt

  • 19. August 2014
slide-41
SLIDE 41

Page-Load Tim imes

What im impact does th the Cache Sketch have?

0,7s 1,8s 2,8s 3,6s 3,4s CALIFORNIEN 0,5s 1,8s 2,9s 1,5s 1,3s FRANKFURT 0,6s 3,0s 7,2s 5,0s 5,7s SYDNEY

0,5s 2,4s 4,0s 5,7s 4,7s TOKYO

slide-42
SLIDE 42

 Cache Sketch: dual approach to web caching for

database services

  • Consistent (Δ-atomic) expiration-based caching
  • Invalidation-based caching with minimal purges

 Keys Id

Ideas:

  • Maintain Blo

loom fi filt lter of potentially stale objects

  • Let clients handle cache coherence through revali

lidatio ions when an object is contained in the filter

  • Estimate the best TTL

TL based on access statistics

Summary ry

Cached Initialization Δ-Bounded Staleness Conflict- Avoidant Transactions Invalidation Minimization

slide-43
SLIDE 43

Thank you

gessert@informatik.uni-hamburg.de Orestes.info Baqend.com