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
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
Damiano Carra
Computer Science Department University of Verona
Pietro Michiardi
Network and Security Department Eurecom – Sophia Antipolis
2
Conclusions Evaluation Design Background
Background Design Evaluation Conclusions
3
Background
Design Evaluation Conclusions
Conclusions Evaluation Design Background
4
! 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
5
! Memcached divides the
– Based on their sizes
! Example: 3 classes of
– Small – Medium – Large
Conclusions Evaluation Design Background
6
! Memcached divides the
– Based on their sizes
! Example: 3 classes of
– 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
7
Conclusions Evaluation Design Background available memory (divided into slabs)
8
Conclusions Evaluation Design Background
set( )!
available memory (divided into slabs)
9
Conclusions Evaluation Design Background
set( )! set( )!
available memory (divided into slabs)
10
Conclusions Evaluation Design Background
set( )! set( )! set( )!
available memory (divided into slabs)
11
Conclusions Evaluation Design Background
set( )! set( )! set( )! set( )!
available memory (divided into slabs)
12
! After many requests… ! What happens when the cache receives a new ?
Conclusions Evaluation Design Background
set( )!
available memory (divided into slabs)
13
! 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)
14
! 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
15
Background
Design
Evaluation Conclusions
Conclusions Evaluation Background Design
16
! 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
17
! Goal " Minimize the miss ratio ! Assumptions
– MRC are concave – Memory is divided into finite number of blocks
Conclusions Evaluation Background Design
18
! 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
19
! 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
! 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
20
! 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
21
Background Design
Evaluation
Conclusions
Conclusions Design Evaluation Background
22
! 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
23
! 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
24
! We compute the optimal cost hit ratio with the
! Our scheme progressively adapts the slab assignment
– It converges to the
– While Memcached (static assignment) is far from
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 (%)
SAS Memcached
25
! 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
26
! 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 (%)
SAS Memcached 40 50 60 70 80 90 100 10 20 30 40 50 60 70 80 90 100 Byte hit ratio (%) Requests (%)
SAS Memcached
27
Background Testbed Results
Conclusions
Evaluation Design Background Conclusions
28
! Synthetic traces
– We tested different traces derived from the literature
! Calcification
– What happens if the statistical properties of the requested
– The dynamic nature of the scheme solves a problem known in the literature as calcification
Evaluation Design Background Conclusions
29
! 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