>_ IzzyLab

Hands-on task

This task is step 2 of the course “Redis in production”

Who ate Redis's memory

easy~5 min

Redis memory keeps growing, and you need to find the culprit. The database has about fifteen hundred keys of different types.

Find the key that takes the most memory (in bytes, not by element count) and write its name to /root/bigkey.txt.

What you'll practise:
  • redis
  • --bigkeys
  • --memkeys
  • MEMORY USAGE
  • memory diagnostics

Topic breakdown

A single "big key" in Redis is a common source of trouble in production: it eats memory, and operations on it (DEL, HGETALL, migration in a cluster) block the single-threaded server for a long time. redis-cli --bigkeys helps find such keys: it walks the database with SCAN (without blocking the server like KEYS * does) and shows the largest key of each type — but by element count or string length. --memkeys does the same by actual memory footprint via MEMORY USAGE, accounting for data structure overhead. These are different metrics: a list of 50 thousand tiny elements in a compact encoding can weigh less than a hash with a few thousand fields.

What's checked

  1. the heaviest key found

What it looks like