Why doesn't the CurrItems metric in my Memcached cluster decrease when the keys expire?

2 分的閱讀內容
0

Why doesn't the CurrItems metric in my Memcached cluster decrease when the keys expire?

Resolution

This is an expected behavior. Memcached uses lazy expiration to remove keys when the time to live (TTL) expires. This means that the key isn't removed from the node even though it's expired. However, when someone tries to access an expired key, Memcached checks the key, identifies that the key is expired, and then removes it from memory.

If there are no free chunks or free pages left in the appropriate slab class to accommodate new keys, then Memcached removes the expired keys, or uses a least recently used (LRU) algorithm to evict keys if it can't find an already expired key. The CurrItems metric decreases after the keys are removed from memory.

The lru_crawler thread, which is an optional background thread, also clears expired keys from memory. The lru_crawler is a conservative task, and, even if enabled, has limited action over expired keys. Therefore, even with lru_crawler enabled, it might take some time for the CurrItems metric and keyspace memory to show a decrease in usage.

Use TTL to make a key available for a particular amount of time. When the key becomes invalid (expires), it's eventually removed. Keys can't be retrieved after their expiration time.


Related information

Memcached specific parameters

AWS 官方
AWS 官方已更新 4 年前
沒有評論

相關內容