Eviction removes a nonexpired cache item because the cache has reached its memory limit. When a new key-value pair arrives, the cache must delete an existing item or reject the write. section 11.5 section 11.5.2
Redis and Memcached expose eviction behavior through the Evictions metric. Redis can choose among these policies:
- volatile-lru removes the least recently used key among keys with a TTL; this is Redis’s default. section 11.5.2
- allkeys-lru removes the least recently used key among all keys. section 11.5.2
- volatile-random, allkeys-random, and volatile-ttl remove a random eligible key, a random key, or the key with the shortest TTL. section 11.5.2
- noeviction rejects eviction, so writes can fail when memory is exhausted. section 11.5.2
Detecting an undersized cache
A cache storing 4 KB team leaderboards can hold 262,144 items in 1 GB. More teams create capacity pressure, increasing evictions. Monitor Evictions in CloudWatch and respond by adding TTLs, increasing the node type, or adding shards. A possible alarm watches for a 10-minute average above 1,000. section 11.0 section 11.5.2
