memcached-usage is a tool can help analyzing memcached memory usage in various scenarios.
memcached-usage will spawn a memcached server, fill it up with varying or particular size values, and output a usage report. With the usage report, you can fine tune the related settings e.g. chunk_size, growth_factor. This bundle also included some test scenarios, check it out before write your own.
- memcached
- node
- npm
clone this repo
git clone [email protected]:tarkus/memcached-usage.git
install the dependencies with npm
cd memcached-usage
npm install
now you are ready to run the test scenario
node run.js
or
node server.js
then open it in your browser http://localhost:4000/
Slab is the way memcached used to allocate chunks, basically, they are representing different sizes memory chunks. When you request memory, memcached will calculate the chunk size based on the settings of chunk_size and growth_factor, then give you whether a free chunk or create a new slab class, in closest size.
stats
- general informationstats slabs
- useful information dedicated on slabs class and slab usage.stats settings
- some settings can be set using command options, man memcached for details
You can use memcache-top to monitor memcached status.
Set the fixture size and run through the test, I figure out,
-
if only store fixed size objects, the usage are too dynamical, in range from 50% up to 98%, it's depend on the object size, chunk_size, and growth_factor, the best fit object produces highest usage.
-
if store small objects in varying size, you can get average usage near 93%
-
Storing fixed size objects in memcached is very tricky, you need to carefully adjust the chunk_size and growth_factor to match the object size.
-
Using memcached as a pool to store varying size objects is the mature way.
-
Avoiding store big objects into memcached. Besides memcached's 1MB hard limit on object size, you need very special settings to reduce the wasted memory. The usage of store big objects is much lower than store small ones.