Does anybody know how much overhead per single item is required?
When I insert 1 byte key the ‘stats’ command shows 65 bytes being consumed per item.
Is this expected and fixed?
Thanks,
Piotr
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, Memcache’s own data structures eat up more than 50 byte per item. It depends a little on your data and key, so assume 60+ bytes when on a 64 bit machine.
One can see it when looking at memcache’s code: https://github.com/memcached/memcached/blob/master/memcached.h
Here’s what makes up an item:
There are 3 pointers, which on a 64 bit machine sum up to 3 * 8 = 24 byte. There there a two time stamps, which should be 32 bit, so they make 8 byte in total. the following int should be 8 byte, the short should be 2, and u_int8 should be a single byte, so they sum up to 14.
This makes a total of 46 bytes.
If CAS is enable there is a 64 bit CAS value, which adds up 8 bytes: 54 Byte in total
Now it gets messy: Following is character data, where flags and length of data are printed as decimals (code can be found at https://github.com/memcached/memcached/blob/master/items.c, line 80). Given that flag is “0”, key is one char, and data is empty, this makes:
That’s another 10 Byte, making a total of 64 Byte for the smallest possible memcache item size (CAS enabled, you may disable it using the -C option).
If you get 65 Byte, maybe your client set a flag of “10” or such.