Cost-based Memory Partitioning and Management in Memcached Damiano - - PowerPoint PPT Presentation

cost based memory partitioning and management in memcached
SMART_READER_LITE
LIVE PREVIEW

Cost-based Memory Partitioning and Management in Memcached Damiano - - PowerPoint PPT Presentation

Cost-based Memory Partitioning and Management in Memcached Damiano Carra Pietro Michiardi Computer Science Department Network and Security Department University of Verona Eurecom Sophia Antipolis Background Design Evaluation


slide-1
SLIDE 1

Cost-based Memory Partitioning and Management in Memcached

Damiano Carra

Computer Science Department University of Verona

Pietro Michiardi

Network and Security Department Eurecom – Sophia Antipolis

slide-2
SLIDE 2

2

Outline

Conclusions Evaluation Design Background

Background Design Evaluation Conclusions

slide-3
SLIDE 3

3

Outline

Background

Design Evaluation Conclusions

Conclusions Evaluation Design Background

slide-4
SLIDE 4

4

Memcached

! Key-value store

– Simple APIs: set, get, delete, …

! Common component of Web architectures

– Caching layer

! All data is kept in RAM

– Fast response time

Conclusions Evaluation Design Background

slide-5
SLIDE 5

5

Memory management: Classes and Slabs

! Memcached divides the

  • bjects into classes

– Based on their sizes

! Example: 3 classes of

  • bjects

– Small – Medium – Large

Conclusions Evaluation Design Background

slide-6
SLIDE 6

6

Memory management: Classes and Slabs

! Memcached divides the

  • bjects into classes

– Based on their sizes

! Example: 3 classes of

  • bjects

– Small – Medium – Large

! Memory is divided into blocks called slabs

– Default size of a slab: 1 MB

! A slab contains a variable number of objects

– Many small ones – Some medium – Few large

Conclusions Evaluation Design Background

slide-7
SLIDE 7

7

Slabs are assigned to classes upon request

Conclusions Evaluation Design Background available memory (divided into slabs)

slide-8
SLIDE 8

8

Slabs are assigned to classes upon request

Conclusions Evaluation Design Background

set( )!

available memory (divided into slabs)

slide-9
SLIDE 9

9

Slabs are assigned to classes upon request

Conclusions Evaluation Design Background

set( )! set( )!

available memory (divided into slabs)

slide-10
SLIDE 10

10

Slabs are assigned to classes upon request

Conclusions Evaluation Design Background

set( )! set( )! set( )!

available memory (divided into slabs)

slide-11
SLIDE 11

11

Slabs are assigned to classes upon request

Conclusions Evaluation Design Background

set( )! set( )! set( )! set( )!

available memory (divided into slabs)

slide-12
SLIDE 12

12

Slabs are assigned to classes upon request

! After many requests… ! What happens when the cache receives a new ?

Conclusions Evaluation Design Background

set( )!

available memory (divided into slabs)

slide-13
SLIDE 13

13

Slabs are assigned to classes upon request

! After many requests… ! What happens when the cache receives a new ?

– LRU eviction within the class

Conclusions Evaluation Design Background

set( )!

available memory (divided into slabs)

slide-14
SLIDE 14

14

Key challenges

! How the memory can be divided among the classes?

– Static vs dynamic assignment

! What are the criteria used to assign the memory

– Hit-ratio vs cost-hit-ratio

Conclusions Evaluation Design Background

slide-15
SLIDE 15

15

Outline

Background

Design

Evaluation Conclusions

Conclusions Evaluation Background Design

slide-16
SLIDE 16

16

Miss-ratio curves (MRC)

! Given a trace and an eviction policy, we can compute the MRC

– What would be the miss ratio if the class had that specific memory assigned?

! MRC can be found with a single pass of the traces

– Mattson stack algorithm

Conclusions Evaluation Background Design

0.7 0.75 0.8 0.85 0.9 0.95 1 200 400 600 800 1000 Miss Ratio (%) Memory Size (MB) Class 12 Class 8 Class 5

slide-17
SLIDE 17

17

Optimal offline slab assignment

! Goal " Minimize the miss ratio ! Assumptions

– MRC are concave – Memory is divided into finite number of blocks

Conclusions Evaluation Background Design

slide-18
SLIDE 18

18

Online slab assignment

! The offline optimal slab assignment can be used as a reference

– It can be computed once we have the whole trace

! We provide a heuristic for the online assignment ! Before showing the heuristic, we consider the object costs

Conclusions Evaluation Background Design

slide-19
SLIDE 19

19

A new interface

! The interface set(k,v) implies that all the objects have the same cost or weight ! But some objects can be more difficult to obtain

– E.g., simply because they are larger – or because it takes more time to retrieve them from the DB

  • complex query

! We have added a new interface: set(k,v,c)

– The application can associate a cost (or weight) to the object

Conclusions Evaluation Background Design

slide-20
SLIDE 20

20

Slab Allocation Scheme (SAS)

! We define an observation epoch

– E.g., when the system has experienced M misses

! During each epoch, we collect, for each classes:

– The number of (weighted) misses – The number of (weighted) requests

! High number of misses " The class is suffering ! Low number of miss ratio per assigned slab " The class can lose a slab

Conclusions Evaluation Background Design

slide-21
SLIDE 21

21

Outline

Background Design

Evaluation

Conclusions

Conclusions Design Evaluation Background

slide-22
SLIDE 22

22

Settings

! We use a representative Web architecture

– Application server, cache, database

! Trace driven experiment

– Traces collected by a major CDN operator – The objects in the trace are stored in the database – The cost of retrieving the objects is stored in the application server – The sequence of the requests is issued by a client

Conclusions Design Evaluation Background

slide-23
SLIDE 23

23

About the traces

! The costs of the objects are not correlated with the sizes

– Correlation coefficient # 0.013

Conclusions Design Evaluation Background 100 101 102 103 104 100 101 102 103 104 105 106 107 Number of requests Object rank 100 101 102 103 104 100 101 102 103 104 105 106 Object cost Object size (byte) Number of requests Object cost

slide-24
SLIDE 24

24

Results

! We compute the optimal cost hit ratio with the

  • ffline algorithm

! Our scheme progressively adapts the slab assignment

– It converges to the

  • ptimal

– While Memcached (static assignment) is far from

  • ptimal

Conclusions Design Evaluation Background

40 50 60 70 80 90 100 10 20 30 40 50 60 70 80 90 100 Cost hit ratio (%) Requests (%)

  • ptimal

SAS Memcached

slide-25
SLIDE 25

25

Results: slab assignment

! Snapshot taken when half of the requests has been processed by the client ! Comparison with the

– Optimal assignment (offline) – Static assignement (Memecached)

Conclusions Design Evaluation Background

1 10 100 5 10 15 20 25 30 Number of slabs Class ID Optimal SAS Memcached

slide-26
SLIDE 26

26

Results: Different Costs

! All objects have the same cost ! The cost of the object is given by its size

Conclusions Design Evaluation Background 40 50 60 70 80 90 100 10 20 30 40 50 60 70 80 90 100 Hit ratio (%) Requests (%)

  • ptimal

SAS Memcached 40 50 60 70 80 90 100 10 20 30 40 50 60 70 80 90 100 Byte hit ratio (%) Requests (%)

  • ptimal

SAS Memcached

slide-27
SLIDE 27

27

Outline

Background Testbed Results

Conclusions

Evaluation Design Background Conclusions

slide-28
SLIDE 28

28

Discussion

! Synthetic traces

– We tested different traces derived from the literature

! Calcification

– What happens if the statistical properties of the requested

  • bjects change?

– The dynamic nature of the scheme solves a problem known in the literature as calcification

Evaluation Design Background Conclusions

slide-29
SLIDE 29

29

Conclusions

! Memcached: in-memory key value store largely adopted…

– Facebook, Twitter

! .. with a specific memory allocation scheme

– Slabs, Classes, LRU within the same class

! We provide a scheme for dynamically assigning the slabs to the different classes

– Trying to minimize the number of (weighted) misses – Many solutions proposed in the literature not applicable to Memcached due to its memory allocation scheme

Evaluation Design Background Conclusions

slide-30
SLIDE 30

Thanks!