Really, I only want to know what are slabs in memcached. And could be better if someine who is working know with can answer me. Thanks for your answers...
Applications that run for long periods of time, like memcached, run into memory fragmentation issues the longer the service runs. On top of that caching applications have the added issue that there are pieces of memory that have been cached for long periods of time as well as newer pieces of memory that were recently allocated.
Memcached has a "slab" allocator that attempts to reduce memory fragmentation in the memcached process. At a high level a slab is a 1MB piece of memory that contains the values of the key-value pairs you store in memcached. There are also different slabs for different value sizes. There might be a slab for 16B values, a a slab for 32B values, a slab for 1024B values, etc. When a new key-value pair is added memcached puts the value in the smallest slab that will hold the value. By allocating memory like this memcached is able to reduce memory fragmentation and as a result reduce the overall amount of memory used by memcached.
Slabs and the slab allocator are internal memcached implementation details. You can get information about them through the stats command, but unless you're trying to debug an issues with memcached itself inspecting the slab information is unlikely to be useful.
For more details about slabs and the slab allocator I found a blog post linked below.
https://holmeshe.me/understanding-memcached-source-code-I/
If you're particularly interested in this kind of architecture then look into how memory allocators work in general since the concepts are similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With