Memory slabs and a timer wheel inside one server

video locked
Enroll to watch

9 mins

Chapters
About
Discussion0
Notes
Be the first to start a conversation!

Adaptive memory slabs are the sizes of memory a memcached server stores its objects in, and the number of blocks it assigns to each size.

Objects of one type are of similar size. Memory slabs are normally given as 1 KB, 2 KB, 4 KB, 8 KB, and those jumps are large. A small object in a large slab wastes the rest of it.

  1. Facebook defines its own slabs, starting from 64 KB: 72, 76, 80, 84, 92, up to 128 and on to 1 MB. The factor is one point zero seven instead of two.
  2. Memcached sees which objects are accessed. If profiles are accessed a lot and groups are not, it evicts the least recently used group and breaks that slab into pieces of 64 KB.
  3. The web server and mcrouter have no idea. A cache can always have a miss.

Short lived items go in a circular buffer of linked lists. Every second the current position moves forward and that linked list is deleted.