DevTools Logo

Redis RDB Memory Estimator

Redis RDB Memory Estimator

Approximate Redis memory from key patterns: jemalloc size classes, embstr and listpack encodings, hash-table overhead.

Runs in your browser
Try an example

Key patterns

PatternTypeKey BValue BElementsField BKeysTTL

Sizes are bytes of the UTF-8 encoding. Hash field names default to 8 bytes when left empty. TTL adds an expires-dictionary entry per key.

Estimated memory

100,000 keys
Approximate estimate, not a measurement. Verify with MEMORY USAGE on real keys before capacity planning.
Approximate: models Redis 7.x on 64-bit jemalloc. Real usage differs by version, allocator, fragmentation, client buffers and your real values. Compare with MEMORY USAGE on sample keys.
Integer-looking string values (up to 20 digits) use a shared or int encoding and are smaller than modelled. Sets of only integers may use intset and are smaller.
Not included: the empty-server baseline (about 1 to 3 MB), client and replica output buffers, AOF rewrite buffers, Lua scripts, pub/sub, and Redis 8 or Valkey 8 key-embedding changes.
During a BGSAVE or full resync, copy-on-write can add up to the size of the dataset again in the worst case. Size the host for that, not for this figure alone.
This estimates in-memory size. An RDB file is a different, usually smaller, serialisation (LZF-compressed strings).
The main dictionary resizes in powers of two; while it grows, the old and new bucket arrays coexist (up to about 3.0 MB of buckets at peak).

Total: about 21.8 MB

Includes 2.0 MB of dictionary bucket arrays, 0 B global overhead and 0 B replication backlog.

PatternEncodingBytes/keyTotal
sessions:*raw20819.8 MB
Assumptions

Redis 7.x on 64-bit jemalloc. Key = dictEntry (24 B, rounded to 32) + SDS key. Strings up to 44 bytes are embstr (one allocation with the 16-byte object header). Listpack limits are the redis.conf defaults (hash 512 entries, set and zset 128, values up to 64 bytes, list nodes 8 KB). Larger collections use hash-table or skiplist overhead. Allocations are rounded to jemalloc size classes.

Model Redis strings, hashes, lists, sets, and sorted sets locally. The deterministic estimate includes 50-byte SDS allocator allowance rounded to 8 bytes, compact encoding thresholds, global overhead, and replication backlog.

Examples

String-heavy session store

Input
estimateRedisMemory([{ name: "sessions:*", type: "string", keyBytes: 32, valueBytes: 64, elements: 0, count: 100000 }])
Output
{ totalBytes: 22400000, patterns: [{ bytesPerKey: 224 }] }

SDS key (88) plus 16-byte object plus SDS value (120) gives 224 bytes per key before count multiplication.

Hash past the ziplist limit

Input
estimateRedisMemory([{ name: "user:*", type: "hash", keyBytes: 24, valueBytes: 20, elements: 129, count: 100 }])
Output
{ patterns: [{ compactEncoding: false }] }

129 elements exceeds the 128-element compact limit, so the regular per-element overhead applies.

About this tool

Redis RDB Memory Estimator projects dataset RAM with estimateRedisMemory(patterns, options): each RedisPatternInput ({ name, type, keyBytes, valueBytes, elements, count }) yields bytesPerKey and totalBytes, plus globalOverheadBytes and replicationBacklogBytes rolled into totalWithOverheadBytes. Keys use an SDS estimate (header plus allocator slack, 8-byte aligned) with a 16-byte object overhead per key.

Compact encodings follow the ziplist thresholds: hashes, lists, sets, and zsets with at most 128 elements and value bytes of 64 or less report compactEncoding true with a small per-element overhead (8 bytes, 16 for zsets); beyond either limit the estimator switches to the regular per-element overhead (24–48 bytes by type). String keys never use the compact path.

Validation is strict and the math is deterministic: blank pattern names, negative or non-finite sizes, and fractional elements/count values throw, while identical inputs always return equal estimate objects — fully client-side with no server round trip.

How to use this tool

  1. Describe each key pattern

    Pass name, type (string/hash/list/set/zset), keyBytes, valueBytes, elements, and count per pattern — counts and elements must be integers.

  2. Add instance overheads

    Set globalOverheadBytes and replicationBacklogBytes in options so totalWithOverheadBytes reflects the full node footprint.

  3. Read the compact flag

    Check compactEncoding per pattern: staying under 128 elements and 64 value bytes keeps hashes, lists, sets, and zsets on the cheap encoding.

  4. Compare and re-run

    Re-run with identical inputs for byte-identical results, then tune sizes or counts to see which pattern dominates totalBytes.

Use cases

Sizing a Redis node before migration

Project totalBytes plus overheads to pick instance RAM with headroom for growth and replication.

Catching ziplist threshold crossings

Spot hashes or zsets that just exceeded 128 elements or 64-byte values and now cost far more per key.

Comparing schema encodings

Contrast string versus hash layouts for the same data to choose the cheaper representation.

Common mistakes

Mistake:Expecting strings to use compact encoding.

Fix:The compact path only applies to hash, list, set, and zset — strings always use the regular SDS plus object overhead.

Mistake:Passing fractional counts or elements.

Fix:Elements and count must be integers; round or floor measured averages before estimating.

Mistake:Ignoring global and replication overhead.

Fix:Read totalWithOverheadBytes, not totalBytes, when sizing the node — the backlog and global overhead are real RAM.

Frequently asked questions

What does this tool do?

It estimates Redis RAM with estimateRedisMemory(patterns, options): per-pattern bytesPerKey and totalBytes with a compactEncoding flag, plus globalOverheadBytes, replicationBacklogBytes, and totalWithOverheadBytes for the node total.

When does a hash use the compact encoding?

When it holds at most 128 elements and value bytes are 64 or less (8 bytes per-element overhead instead of 40). At 129 elements or 65-byte values it flips to the regular encoding — strings never use the compact path.

Is my dataset uploaded or stored?

No. Size math, SDS estimates, and overhead sums run entirely in your browser.

Why did my estimate throw?

Pattern names must be non-blank, sizes must be non-negative finite numbers, and elements/count must be integers — negative counts or fractional elements throw a descriptive error.

References & standards