liveBook · Manning

Eviction

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

An eviction is the removal of a nonexpired cache item because the cache has reached its memory limit.

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

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Explains eviction triggers, Redis policies, monitoring thresholds, and capacity remedies without detailing implementation internals.
Examples
Uses team leaderboards, 4 KB cached items, a 1 GB cache, and a CloudWatch Evictions alarm.
What it assumes
Assumes familiarity with key-value caches and introduces memory limits, TTLs, and eviction policies through Redis examples.
What you can do after
Diagnose cache pressure with CloudWatch and reduce evictions by tuning TTLs, resizing nodes, or adding shards.
How it connects
Connects eviction with cache memory, TTL, LRU, Redis, Memcached, CloudWatch, and sharding.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.