Redis Memory Estimator
Estimate Redis memory from key count, value size and data structure, including the per key overhead people forget, and choose an eviction policy and maxmemory that avoid an OOM.
Last reviewed by the Radiatus Cloud team
Want this automated for your stack?
We build CI/CD, Kubernetes & IaC pipelines that scale.
The overhead per key is larger than the key
Storing a million short strings does not consume a million times the value size. Every key carries a dictionary entry, a robj header, an SDS header for the string, expire metadata if a TTL is set, and allocator rounding. That overhead is roughly fifty to a hundred bytes per key before the data. For small values it dominates completely: a million keys holding twenty byte values use far more memory in bookkeeping than in data, which is why consolidating many small keys into a hash is such an effective optimisation.
Small collections are stored compactly
Redis encodes small hashes, lists, sets and sorted sets as a flat listpack rather than as a full data structure, which removes almost all the per element overhead. The conversion happens automatically once the collection exceeds a configured entry count or element size, and it can multiply memory usage by five or more in a single step. A hash of two hundred fields is often much larger than the same data in two hashes of a hundred, which is unintuitive and easy to trip over at scale.
maxmemory must leave room for the fork
Setting maxmemory to the full container limit is the same mistake as sizing a JVM heap to it. Background saves and replica synchronisation fork the process, and copy on write means the child's memory grows with the write rate during the save. A write heavy instance can briefly need substantially more than its resident size. Leaving twenty to thirty percent headroom, or disabling saves entirely on a pure cache, is what prevents the OOM killer arriving mid-snapshot.
Related tools
- CI/CD Security Gap Analyzer — Checklist based analyzer for CI/CD pipeline security gaps.
- Docker Security Scanner — A new tool extracted from the codebase.
- Terraform Scanner — A new tool extracted from the codebase.
- SQL Formatter — Format and indent SQL queries for readability. Handles joins, subqueries and CTEs, supports common dialects, and runs entirely in your browser.
Frequently Asked Questions
How much memory does a key actually use?
Roughly 50 to 100 bytes of overhead before the value, covering the dictionary entry, object header, string header and allocator rounding. Add about 16 bytes more if the key has a TTL. For small values the overhead exceeds the data.
Why did memory jump suddenly when a collection grew?
It crossed a listpack threshold. Small hashes, lists, sets and sorted sets are stored as a compact flat encoding; past a configured entry count or element size Redis converts to the full structure, which can multiply memory for that key several times over.
Which eviction policy should I use?
allkeys-lru for a pure cache where anything may be discarded. volatile-lru when some keys must persist and only those with a TTL may be evicted. noeviction for a datastore, where the correct behaviour is to reject writes rather than silently lose data. Choosing noeviction for a cache produces write errors under pressure.
Why does memory usage exceed maxmemory?
maxmemory covers the dataset, not the process. Replication buffers, client output buffers, the AOF rewrite buffer and fork copy on write all sit outside it. Leave 20 to 30 percent of the container limit above maxmemory for them.
How do I reduce memory for many small keys?
Group them into hashes. A hash below the listpack threshold stores fields with almost no per field overhead, so ten million keys restructured into hashes of a hundred fields can use a small fraction of the memory, at the cost of losing per key TTLs.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Enter your key count, value sizes and data types to estimate memory and set maxmemory.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.