Redis & Valkey In-Memory Cache Footprint & Reserved Memory Calculator
Interactive Redis & Valkey Memory Sizing & Overhead Calculator
?
Keys held by the instance, in millions (0.5 to 500, step 0.5). Read DBSIZE on each node and sum across shards.?
Average key name length in bytes (4 to 512, step 2). Measure it on a sample of key names.?
Average value payload in bytes (8 to 65536, step 8). Use STRLEN for string values, or the serialized size for hashes.?
Allocator fragmentation ratio, used_memory_rss divided by used_memory, from INFO memory (1.05 to 1.80, step 0.02). Use the value observed on a warm node.?
Reserved memory as a percent of the node's advertised RAM (10 to 50, step 5). It covers fragmentation, client buffers and the copy-on-write pages of a forked BGSAVE. reserved-memory-percent is an Amazon ElastiCache setting, not part of open-source Redis or Valkey; for self-managed nodes use it as headroom. The ElastiCache default is 25%, and AWS says not to reduce it below that default: the pill turns amber under 25%.Use the Redis & Valkey Memory Sizing & Overhead Calculator to evaluate RAM_node = N_keys · (S_key + S_val + 56B) · f_frag / (1 − r_reserve) for AWS ElastiCache Redis/Valkey clusters, session stores. With the defaults (Total Cached Keys = 25 Millions, Average Key Name Length = 36 Bytes, Average Value Payload = 280 Bytes) it returns Raw string payload vs dict overhead: Raw Data = 7.36 GiB · With Pointers = 8.66 GiB. Change any input and the results update from the same equation.
Governing equationRAM_node = N_keys · (S_key + S_val + 56B) · f_frag / (1 − r_reserve) (Model constants (56 B per key, fragmentation 1.22) and the ElastiCache 25 % reserve)
Model assumptions
The ElastiCache reserve already includes fragmentation headroom, so counting the fragmentation ratio and the reserve both is conservative; the single count applies the reserve only. reserved-memory-percent is an Amazon ElastiCache setting, not part of open-source Redis or Valkey; for self-managed nodes use it as headroom.
Why Redis Needs More RAM Than the Raw Key and Value Bytes
Redis and Valkey keep the dataset in RAM, and the bytes you store are only part of what they hold. Each key carries object and dictionary structures on top of its name and value, the allocator rounds allocations and leaves fragmentation, and a background save forks the process so that writes made during the save copy memory pages. Sizing from key plus value bytes alone misses all three.
Redis documents a compact encoding for small aggregate types. Hashes, lists, sets of integers and sorted sets use it while they stay under configurable limits, which default to 512 fields and 64-byte values for hashes in Redis 7 (redis.io/docs/latest/operate/oss_and_stack/management/optimization/memory-optimization/). The same page notes that RSS keeps the peak after keys are deleted, so the fragmentation ratio is misleading after large deletions. The INFO field mem_fragmentation_ratio is used_memory_rss divided by used_memory (redis.io/docs/latest/commands/info/).
| Key Count | Raw Data (GiB) | With 56B Pointers | Fragmented RSS (GiB) | Total Node RAM Needed |
|---|---|---|---|---|
| 5M Keys | 1.47 GiB | 1.73 GiB | 2.11 GiB | 2.82 GiB |
| 10M Keys | 2.94 GiB | 3.46 GiB | 4.23 GiB | 5.64 GiB |
| 25M Keys | 7.36 GiB | 8.66 GiB | 10.57 GiB | 14.09 GiB |
| 50M Keys | 14.71 GiB | 17.32 GiB | 21.13 GiB | 28.18 GiB |
| 100M Keys | 29.43 GiB | 34.65 GiB | 42.27 GiB | 56.36 GiB |
| 200M Keys | 58.86 GiB | 69.29 GiB | 84.53 GiB | 112.71 GiB |
The Calculator's Per-Key and Node Equations
The calculator computes raw bytes as N x (key + value); with pointers as N x (key + value + 56 B); fragmented as that times f; and node RAM as fragmented divided by (1 - r), where r is the reserved-memory share of the node. The 56-byte per-key overhead and the 1.22 default fragmentation ratio are model values. The Redis pages above describe the mechanisms and the INFO ratio but do not publish these constants, so they remain gaps. The fragmentation factor is applied in addition to the reserve, although the ElastiCache reserve already includes fragmentation headroom, so the result can count fragmentation twice and should be read as a conservative sizing model. The single count, with_pointers / (1 - r), applies the reserve only: 8.66 / 0.75 = 11.55 GiB at the defaults, against 14.09 GiB when both are counted. Measure per-key memory with MEMORY USAGE on a sample of real keys, and read f from INFO memory on a warm node.
The reserve follows the one Amazon ElastiCache uses for Redis and Valkey. reserved-memory-percent defaults to 25% of advertised memory and sets aside memory for client output buffers, fragmentation and the copy-on-write pages of a forked bgSave, and maxmemory equals the advertised memory minus that reserve (docs.aws.amazon.com/AmazonElastiCache/latest/dg/redis-memory-management.html). Its example of a 13.5 GB node gives about 10.1 GB of maxmemory, so the reserve is a share of the node and not an addition to the data. For the default 25 million keys with 36-byte names and 280-byte values, the calculator gives 7.36 GiB of raw data, 8.66 GiB with per-key overhead, 10.57 GiB after fragmentation and 14.09 GiB of node RAM (10.57 / 0.75 with a 25% reserve), which is 91.5% above the raw bytes. The single count, without the separate fragmentation factor, is 11.55 GiB.
| Key / Value Size | Raw Payload (GiB) | With 56B Metadata | Total Node RAM (GiB) | Overhead (%) |
|---|---|---|---|---|
| 24B / 16B | 0.93 GiB | 2.24 GiB | 3.64 GiB | +290.4% |
| 32B / 64B | 2.24 GiB | 3.54 GiB | 5.76 GiB | +157.6% |
| 36B / 128B | 3.82 GiB | 5.12 GiB | 8.33 GiB | +118.2% |
| 36B / 280B | 7.36 GiB | 8.66 GiB | 14.09 GiB | +91.5% |
| 48B / 1024B | 24.96 GiB | 26.26 GiB | 42.72 GiB | +71.2% |
| 64B / 4096B | 96.86 GiB | 98.16 GiB | 159.68 GiB | +64.9% |
Worked Examples: Two Presets Calculated with RAM_node = N_keys · (S_key + S_val + 56B) · f_frag / (1 − r_reserve)
Worked Example 1 (10M sessions, 1 KB JSON values, 1.10 fragmentation, 15% CoW reserve): This preset sets Total Cached Keys = 10 Millions, Average Key Name Length = 36 Bytes, Average Value Payload = 1024 Bytes, jemalloc Fragmentation Ratio = 1.1, Reserved Memory, % of Node RAM = 15. Evaluating RAM_node = N_keys · (S_key + S_val + 56B) · f_frag / (1 − r_reserve) gives: raw key and value data = 9.87 GiB, with 56 B per-key overhead = 10.39 GiB, after fragmentation = 11.43 GiB, node RAM with reserve = 13.45 GiB, overhead above raw data = 36.2 %, node RAM, single count = 12.23 GiB. Related in the Cloud, API, LLM & Automation Hub: Vector Database HNSW Index RAM & Disk Calculator (another in-memory index sized in RAM) and PostgreSQL Memory Tuning & PgBouncer Pool Calculator (the relational database that often sits behind the cache).
Worked Example 2 (50M rate-limit counters, 64 B values, 30% reserved memory): This preset sets Total Cached Keys = 50 Millions, Average Key Name Length = 24 Bytes, Average Value Payload = 64 Bytes, jemalloc Fragmentation Ratio = 1.25, Reserved Memory, % of Node RAM = 30. The calculator returns: raw key and value data = 4.1 GiB, with 56 B per-key overhead = 6.71 GiB, after fragmentation = 8.38 GiB, node RAM with reserve = 11.97 GiB, overhead above raw data = 192.2 %, node RAM, single count = 9.58 GiB. You can compare these limits with other calculators in the Engineering Studio.
How to Evaluate Small Values, Hash Grouping and the Limits?
Small values raise the relative overhead sharply. The 25-million-key case with 24-byte names and 40-byte values stores 1.49 GiB of raw data but needs 4.54 GiB of node RAM, which is 205.0% above raw. Grouping such keys into hashes keeps them in the compact encoding while the limits hold, and the Redis memory-optimization page says that small encoded aggregates use up to 10 times less memory, 5 times on average (redis.io/docs/latest/operate/oss_and_stack/management/optimization/memory-optimization/, checked November 2026). Check the field count and the value size against those limits first, because a hash that grows past either one converts to the normal encoding.
Download the data on this page (CC BY 4.0, checked 2026-12-02): CSV Redis / Valkey RAM Requirement by Key Count (36B Key, 280B Value, 1.22 Fragmentation, 25% Reserved Memory) — Computed via RAM_node = N_keys · (S_key + S_val + 56B) · f_frag / (1 − r_reserve) (Model constants (56 B per key, fragmentation 1.22) and the ElastiCache 25 % reserve) · Sources checked November 2026; Total node RAM vs raw payload (%) by key and value size (25 Million Keys, 1.22 Fragmentation, 25% Reserved Memory; the overhead column includes per-key metadata, fragmentation and the reserve, which are counted separately) — Computed via RAM_node = N_keys · (S_key + S_val + 56B) · f_frag / (1 − r_reserve) (Model constants (56 B per key, fragmentation 1.22) and the ElastiCache 25 % reserve) · Sources checked November 2026; all tables as JSON. More files on Data & How to Cite.
Sources
- Redis · Memory optimizationSmall hashes, lists and sorted sets use a compact encoding (up to 10 times less memory, 5 times on average) under configurable limits (hash-max-listpack-entries 512 and hash-max-listpack-value 64 by default in Redis 7). RSS keeps the peak after keys are deleted, so the fragmentation ratio is misleading after large deletions. Basis of the hash-grouping advice and the fragmentation caveat.
- Redis · INFO command (memory section)Defines mem_fragmentation_ratio as used_memory_rss divided by used_memory. Basis of the fragmentation input. The 1.22 default is a model value, not a documented one.
- AWS · ElastiCache for Valkey and Redis OSS, managing reserved memoryreserved-memory-percent defaults to 25% and covers client output buffers, fragmentation and copy-on-write memory for a forked bgSave. maxmemory equals the advertised memory minus the reserve, so the calculator treats the percentage as a share of node RAM: node RAM = fragmented / (1 - r). Example: 13.5 GB advertised gives about 10.1 GB maxmemory. The 1.22 fragmentation factor is applied in addition to the reserve, which can count fragmentation twice; the single count (reserve only) is shown beside it. The page also states that reserved-memory-percent is specific to ElastiCache and is not part of the Valkey or Redis OSS code.
- Redis · redis.conf (7.2), listpack limitsConfirms the shipped defaults hash-max-listpack-entries 512 and hash-max-listpack-value 64 (checked November 2026). Basis of the hash-grouping limits in the text.
Method and test suite: Calculation Methodology.
Frequently Asked Questions: Redis & Valkey Memory Sizing & Overhead Calculator
What does a fragmentation ratio above 1.5 mean?
By the INFO definition it is RSS divided by used memory. A high ratio after many deletions usually reflects memory the allocator has not returned, because RSS keeps the peak. Compare peak and current use before you change the fragmentation input.
Why is the node sized above the fragmented figure?
The reserved-memory share covers client buffers, fragmentation headroom and the pages copied while a forked save runs. ElastiCache reserves 25% of the advertised memory by default, so the node must be larger than the fragmented data by 1 / (1 - 0.25), a factor of 1.33. The result is a sizing model, not a guarantee.
Do keys with a TTL cost more?
The model applies one per-key overhead term to every key and does not separate keys with an expiry. Measure a sample of real keys, with and without TTL, before you rely on the figure.
Which encoding do small hashes use?
In Redis 7 the default limits are 512 fields and 64-byte values for hashes (hash-max-listpack-entries and hash-max-listpack-value). Above either limit Redis converts the hash to the normal encoding and the saving is lost.