Memcached eviction limits under per-slab LRU pressure
0 reputation · 23 Jan 2022, 21:00 UTC
Objective
Define a predictable retention policy for hot cache entries when a memcached node approaches its configured memory limit. Memcached allocates fixed-size chunks in slab classes, and each class maintains its own LRU queue; there is no global LRU ordering across classes. Free memory in another class therefore does not necessarily protect an item from eviction when its own class needs space.
The policy must account for the default 1 MB maximum item size and the 250-byte maximum key length, and it must distinguish expired-item reclamation from eviction of live, least-recently-used items. The unresolved decision is whether per-class eviction is acceptable for the workload, or whether hot-key retention requires a stronger guarantee that memcached does not itself provide.
Which slab-class occupancy and eviction counters should be the acceptance criteria for the policy?
Should the priority be preventing hot-key eviction over maximizing total cache utilization, and how should that trade-off be measured?