Easy Freshness with Pequod Cache Joins Bryan Kate, Eddie Kohler, - - PowerPoint PPT Presentation

easy freshness with pequod cache joins
SMART_READER_LITE
LIVE PREVIEW

Easy Freshness with Pequod Cache Joins Bryan Kate, Eddie Kohler, - - PowerPoint PPT Presentation

Easy Freshness with Pequod Cache Joins Bryan Kate, Eddie Kohler, Mike Kester Harvard University Yandong Mao, Neha Narula, Robert Morris MIT tl;dr Web application caches should support materialized views natively. In-cache materialized views


slide-1
SLIDE 1

Easy Freshness with Pequod Cache Joins

Bryan Kate, Eddie Kohler, Mike Kester Harvard University Yandong Mao, Neha Narula, Robert Morris MIT

slide-2
SLIDE 2

tl;dr

Web application caches should support materialized views natively. In-cache materialized views are easy to use and have good performance.

2

slide-3
SLIDE 3

application cache

  • fast key-value cache

– examples: memcached, Redis

  • offloads reads from database
  • managed by application developer

– assume burden of maintenance

3

slide-4
SLIDE 4

4

slide-5
SLIDE 5

5

slide-6
SLIDE 6

6

100 timeline checks for every new post!

slide-7
SLIDE 7

7

slide-8
SLIDE 8

8

slide-9
SLIDE 9

9

slide-10
SLIDE 10

10

slide-11
SLIDE 11

11

slide-12
SLIDE 12

12

slide-13
SLIDE 13

timeline database query

13

SELECT ¡post.time, ¡post.poster, ¡post.content ¡ ¡ ¡ ¡FROM ¡post ¡JOIN ¡sub ¡ ¡ ¡ ¡ ¡WHERE ¡sub.follows ¡= ¡post.poster ¡ ¡ ¡ ¡ ¡ ¡ ¡AND ¡sub.user ¡= ¡'bk' ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡AND ¡post.time ¡>= ¡100 ¡ ¡ ¡ ¡ORDER ¡BY ¡post.time; ¡ ¡

slide-14
SLIDE 14

14

slide-15
SLIDE 15

timeline materialized view

CREATE ¡MATERIALIZED ¡VIEW ¡tline ¡AS ¡ SELECT ¡sub.user, ¡post.time, ¡post.poster, ¡post.content ¡ ¡ ¡ ¡FROM ¡post ¡JOIN ¡sub ¡ ¡ ¡ ¡ ¡WHERE ¡sub.follows ¡= ¡post.poster; ¡ ¡ ¡ SELECT ¡* ¡FROM ¡tline ¡ ¡ ¡WHERE ¡tline.user ¡= ¡‘bk’ ¡AND ¡tline.time ¡>= ¡100 ¡ ¡ ¡ORDER ¡BY ¡tline.time; ¡

  • arrange data for quick reading

– computation happens in advance—good! – simple query on materialized data—good!

15

slide-16
SLIDE 16

16

slide-17
SLIDE 17

easy, but slow

  • the database becomes a bottleneck

– most important job: durable storage – handling reads + writes may be too much – better to offload reads – implementation issues (locks, transactions, …)

17

slide-18
SLIDE 18

18

slide-19
SLIDE 19

Pequod

  • a distributed application cache
  • materialized views in a key-value cache

– operations: get, put, scan, plus join

  • good performance and programmability

19

slide-20
SLIDE 20

advanced materialized views

  • simple materialized views are a bad fit for caches

– need advanced features from recent research

  • partial: only portions are materialized as needed
  • dynamic: portions are selected based on requests
  • incremental updates: track dependencies between data
  • eager updates
  • lazy updates
  • distributed
  • in an ordered key-value cache!

20

slide-21
SLIDE 21

KV materialized views?

21

CREATE ¡MATERIALIZED ¡VIEW ¡tline ¡AS ¡ SELECT ¡sub.user. ¡post.time, ¡post.poster, ¡post.content ¡ ¡ ¡ ¡FROM ¡post ¡JOIN ¡sub ¡ ¡ ¡ ¡ ¡WHERE ¡sub.follows ¡= ¡post.poster; ¡ ¡

  • but Pequod only understands get, put, scan!

– want key-value for performance – how to represent the relations needed for views?

slide-22
SLIDE 22

Pequod cache joins

22

tline|<user>|<time>|<poster> ¡= ¡ ¡ ¡check ¡sub|<user>|<poster> ¡ ¡ ¡copy ¡post|<poster>|<time>;

CREATE ¡MATERIALIZED ¡VIEW ¡tline ¡AS ¡ SELECT ¡sub.user. ¡post.time, ¡post.poster, ¡post.content ¡ ¡ ¡ ¡FROM ¡post ¡JOIN ¡sub ¡ ¡ ¡ ¡ ¡WHERE ¡sub.follows ¡= ¡post.poster; ¡ ¡

slide-23
SLIDE 23

Pequod cache joins

23

tline|<user>|<time>|<poster> ¡= ¡ ¡ ¡check ¡sub|<user>|<poster> ¡ ¡ ¡copy ¡post|<poster>|<time>;

CREATE ¡MATERIALIZED ¡VIEW ¡tline ¡AS ¡ SELECT ¡sub.user. ¡post.time, ¡post.poster, ¡post.content ¡ ¡ ¡ ¡FROM ¡post ¡JOIN ¡sub ¡ ¡ ¡ ¡ ¡WHERE ¡sub.follows ¡= ¡post.poster; ¡ ¡

slide-24
SLIDE 24

Pequod cache joins

24

tline|<user>|<time>|<poster> ¡= ¡ ¡ ¡check ¡sub|<user>|<poster> ¡ ¡ ¡copy ¡post|<poster>|<time>; ¡ ¡ scan(tline|bk|100, ¡tline|bk∞) ¡

CREATE ¡MATERIALIZED ¡VIEW ¡tline ¡AS ¡ SELECT ¡sub.user. ¡post.time, ¡post.poster, ¡post.content ¡ ¡ ¡ ¡FROM ¡post ¡JOIN ¡sub ¡ ¡ ¡ ¡ ¡WHERE ¡sub.follows ¡= ¡post.poster; ¡ ¡

slide-25
SLIDE 25

25

slide-26
SLIDE 26

26

scan(tline|bk|100, ¡tline|bk∞) ¡

slide-27
SLIDE 27

27

scan(tline|bk|100, ¡tline|bk∞) ¡ ¡ tline|<user>|<time>|<poster> ¡= ¡ ¡ ¡check ¡sub|<user>|<poster> ¡ ¡ ¡copy ¡post|<poster>|<time>; ¡

slide-28
SLIDE 28

28

slide-29
SLIDE 29

29

slide-30
SLIDE 30

30

slide-31
SLIDE 31

scale

  • distributed Pequod scales to large data sets

– key design choice: computation is local

  • base data is partitioned

– example: sub, post “tables”

  • cache joins can be computed anywhere

– base data transparently replicated as necessary

31

slide-32
SLIDE 32

distributed deployment

32

slide-33
SLIDE 33

distributed deployment (read)

33

slide-34
SLIDE 34

distributed deployment (read)

34

slide-35
SLIDE 35

distributed deployment (read)

35

slide-36
SLIDE 36

distributed deployment (write)

36

slide-37
SLIDE 37

distributed deployment (write)

37

slide-38
SLIDE 38
  • ther features
  • advanced cache joins

– interleaved: collocate different kinds of data – stacked – materialized, non-materialized, or snapshot – aggregates

  • eviction
  • consistency

38

slide-39
SLIDE 39

evaluation

  • Twitter-like benchmark

– based on 2009 Twitter social graph – check, subscribe, post (100:10:1)

  • evaluate potential bottlenecks in Pequod

– database omitted in experiments – clients write data directly to Pequod

39

slide-40
SLIDE 40

system comparison

Do cache joins have key-value cache performance?

  • goal: perform no worse than existing caches
  • compare with:

– fast KV caches: Redis, memcached – DB-as-cache: Postgres (in-memory, tuned)

  • Postgres uses “materialized views” (triggers)

40

slide-41
SLIDE 41

system comparison

41

50 100 150 200 250 300 350 Pequod Redis memcached Postgres

QPS (thousands / s)

slide-42
SLIDE 42

scaling Pequod

Will adding servers improve performance? What is the overhead of data movement?

  • cluster on Amazon EC2
  • two-tier deployment

– subscriptions, posts on “base” servers – timelines executed on “compute” servers – replication is required

42

slide-43
SLIDE 43

scaling Pequod

1 2 3 4 5 12 24 36 48 QPS (millions / s) Compute servers

43

slide-44
SLIDE 44

scaling Pequod (overhead)

  • steady-state bandwidth for data movement

– 10 è 16% (larger fanout)

  • total memory consumption

– 290 è 297GB at base (subscription metadata) – 1.2 è 1.5TB at compute (duplicate data)

  • overhead is noticeable but not crippling

44

slide-45
SLIDE 45

selected related work

  • DMV [Zhou et al, 2007]

– partial, dynamic database materialized views

  • DBProxy [Amiri et al, 2002-3]

– distributed cache built from databases – incremental updates to cached results

  • MV in PNUTS [Agrawal et al, 2009]

– materialized views in a key-value store – incremental updates, not partial

45

slide-46
SLIDE 46

conclusion

  • Pequod cache joins

– programmability of materialized views – performance of a key-value cache – code release soon! github.com/bryankate

46