memcached Slabs Statistics

To get the slabs statistics, use the stats slabs command, or the API equivalent.

The slab statistics provide you with information about the slabs that have created and allocated for storing information within the cache. You get information both on each individual slab-class and total statistics for the whole slab.

STAT 1:chunk_size 104
STAT 1:chunks_per_page 10082
STAT 1:total_pages 1
STAT 1:total_chunks 10082
STAT 1:used_chunks 10081
STAT 1:free_chunks 1
STAT 1:free_chunks_end 10079
STAT 9:chunk_size 696
STAT 9:chunks_per_page 1506
STAT 9:total_pages 63
STAT 9:total_chunks 94878
STAT 9:used_chunks 94878
STAT 9:free_chunks 0
STAT 9:free_chunks_end 0
STAT active_slabs 2
STAT total_malloced 67083616

Individual stats for each slab class are prefixed with the slab ID. A unique ID is given to each allocated slab from the smallest size up to the largest. The prefix number indicates the slab class number in relation to the calculated chunk from the specified growth factor. Hence in the example, 1 is the first chunk size and 9 is the 9th chunk allocated size.

The different parameters returned for each chunk size and the totals are shown in the following table.

chunk_sizeSpace allocated to each chunk within this slab class. 
chunks_per_pageNumber of chunks within a single page for this slab class. 
total_pagesNumber of pages allocated to this slab class. 
total_chunksNumber of chunks allocated to the slab class. 
used_chunksNumber of chunks allocated to an item.. 
free_chunksNumber of chunks not yet allocated to items. 
free_chunks_endNumber of free chunks at the end of the last allocated page. 
get_hitsNumber of get hits to this chunk1.3.x
cmd_setNumber of set commands on this chunk1.3.x
delete_hitsNumber of delete hits to this chunk1.3.x
incr_hitsNumber of increment hits to this chunk1.3.x
decr_hitsNumber of decrement hits to this chunk1.3.x
cas_hitsNumber of CAS hits to this chunk1.3.x
cas_badvalNumber of CAS hits on this chunk where the existing value did not match1.3.x
mem_requestedThe true amount of memory of memory requested within this chunk1.4.1

The following additional statistics cover the information for the entire server, rather than on a chunk by chunk basis:

active_slabsTotal number of slab classes allocated. 
total_mallocedTotal amount of memory allocated to slab pages. 

The key values in the slab statistics are the chunk_size, and the corresponding total_chunks and used_chunks parameters. These given an indication of the size usage of the chunks within the system. Remember that one key/value pair is placed into a chunk of a suitable size.

From these stats, you can get an idea of your size and chunk allocation and distribution. If you store many items with a number of largely different sizes, then you may want to adjust the chunk size growth factor to increase in larger steps to prevent chunk and memory wastage. A good indication of a bad growth factor is a high number of different slab classes, but with relatively few chunks actually in use within each slab. Increasing the growth factor creates fewer slab classes and therefore makes better use of the allocated pages.

Design by styleshout