Issue
For debugging purposes I want to count the number of keys in our memcache server, so I did some research and ended up using the memdump
utility, which seems to come with libmemcached.
In the description of the command it says:
memdump dumps a list of “keys” from all servers that it is told to fetch from. Because memcached does not guarentee to provide all keys it is not possible to get a complete “dump”.
Also on another website (Memcached Cheat Sheet) I read:
[…] The memcache protocol provides commands to peek into the data that is organized by slabs (categories of data of a given size range). There are some significant limitations though:
You can only dump keys per slab class (keys with roughly the same content size)
You can only dump one page per slab class (1MB of data)
This is an unofficial feature that might be removed anytime.
[…]
So what does You can only dump one page per slab class (1MB of data)
mean in practice? One megabyte of data is what? If a slab contains more than 1 MB of data (including keys?) then the remaining data will not be fetched and i might miss some keys?
As an exmaple, I have 3 keys A with 500 KB of data, B with another 600 KB of data and C with 300 KB of data, they all go to the same slab. Then when dumping the keys, only A and B will be dumped with the data (which might then also be cut off?)
Solution
memdump
utility employs memcache protocol undocumented command stats cachedump
to obtain list of keys by slab id. You can look in stats cachedump <slabs_id> <limit>
implementation in memcached source code items.c:
char *item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes) {
unsigned int memlimit = 2 * 1024 * 1024; /* 2MB max response size */
while (it != NULL && (limit == 0 || shown < limit)) {
// ... key copying occurs here
if (bufcurr + len + 6 > memlimit) /* 6 is END\r\n\0 */
break;
// ...
}
So it is impossible without recompiling memcached to get more than 2 Mb of keys per slab given. Values are not copied to response buffer, response size limit applies only to keys.
Answered By - Alexander Yanyshin Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.