Skip to content

How do I resolve a CurrItems metric that doesn’t decrease when keys expire in my ElastiCache for Memcached cluster?

2 minute read
0

I want to resolve a CurrItems metric that doesn’t decrease when keys expire in my Amazon ElastiCache for Memcached cluster.

Short description

The CurrItems metric indicates the number of items that are currently stored in the cache. It's normal behavior for the CurrItems metric in your ElastiCache for Memcached cluster to not decrease when keys expire. In ElastiCache for Memcached, you can specify a time to live (TTL) that determines how long keys remain in the cache before expiration. Keys can't be retrieved after their TTL expiration.

Resolution

ElastiCache for Memcached doesn't remove keys immediately when their TTL expires. When a user tries to access an expired key, Memcached checks the key. Then it identifies that the key is expired and removes the key from memory. Also, if there's no free space or free pages left in the appropriate slab class, then Memcached removes expired or the least recently used keys. The CurrItems metric decreases after keys are removed from memory.

Optionally, The lru_crawler thread is a background thread that removes expired keys from memory. Lru_crawler is a conservative task that has limited action over expired keys. To use the lru_crawler thread, turn it on through a parameter group. It might take time for the CurrItems metric and keyspace memory to show a decrease in usage.

Note: An ElastiCache for Memcached cluster that's managed through a parameter group doesn't apply to Amazon ElastiCache Serverless.

AWS OFFICIALUpdated 2 years ago