Redis Key Count to Memory

Give an average key and value size and see the total at several scales, plus how much of it is overhead rather than data.

Paste below, or drop a file anywhere on this panel

Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.

The answer appears here

Paste on the left and press Calculate. Nothing leaves this tab.

Wanted a different tool?

  • Redis Memory Calculator if the keys hold hashes, sets or lists rather than plain strings, because then the encoding decides the answer and a per-key figure will understate it.

Examples

Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.

Small values

An 8 byte value under a 30 byte key, where overhead is most of the cost

keys: 1000000
key-bytes: 30
value-bytes: 8

Larger values

A 1 KB value, where the data dominates and overhead is noise

keys: 1000000
key-bytes: 30
value-bytes: 1024

Common mistakes

These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

  1. Storing many small values as separate keys

    Each pays the full per-key cost. A hundred keys of 8 bytes costs far more than one hash with a hundred fields.

    Instead:Group related values into a hash, which pays the per-key overhead once.

  2. Using long descriptive key prefixes

    The name is stored in full per key, forever. A 60 byte prefix across ten million keys is 600 MB of prefix.

    Instead:Shorten the prefix. The saving is exact and permanent.

  3. Forgetting the dictionary itself

    The main hash table sizes to a power of two, so it is between one and two pointers per key on top of the entry.

    Instead:Budget for it. It is invisible in any calculation based on key and value size alone.