How the Redis calculator works
This page walks through how the Redis calculator turns your used_memory into
maxmemory and the memory to give the Redis process. It starts from the
shared sizing model; this page covers what happens after that. Statements backed by the
Redis documentation end with a Redis docs link to it. Choices the
documentation doesn't make for us are explained and marked
Assumption, which links to its row in the table of all of them.
01 maxmemory and the eviction policy
-
maxmemoryis the most memory Redis uses for data; past it Redis applies the eviction policy. 0 means no limit, the default on 64-bit systems. Redis docs -
allkeys-lruevicts the least recently used keys, and Redis calls it a good default when you have no reason to prefer another.noevictioninstead returns errors for writes at the limit. Redis docs The calculator writesallkeys-lru, taking this Redis to be a cache. Assumption -
Buffers for replication and the AOF don't count towards
maxmemory, so Redis can use somewhat more. Redis docs
02 From used_memory to maxmemory
maxmemory = max(peak × (1 + limit margin), average × (1 + request margin)) rounded up to a whole mb
memory to provision = 2 × maxmemory
The margins come from the sensitivity, workload type and environment you choose; the sizing
model explains them, and they are assumptions too. In Redis's configuration, mb is 1024 × 1024 bytes,
so MiB pass through unconverted.
Redis docs
The samples are used_memory, which includes Redis's own overhead and not only the data, so a
maxmemory sized from them is on the generous side.
Assumption
Worked example
A cache peaking at 630 MiB of used_memory, medium sensitivity, production:
| maxmemory | 630 MiB × 1.30 = 819 MiB | 819mb |
|---|---|---|
| memory to provision | 2 × 819 | 1638 MiB |
A steady cache, averaging 1000 MiB with a 1010 MiB peak at high sensitivity, where the average decides:
| maxmemory | 1000 MiB × 1.55 = 1550 MiB, above 1010 × 1.40 = 1414 | 1550mb |
|---|---|---|
| memory to provision | 2 × 1550 | 3100 MiB |
03 Memory for the process
- In a write-heavy application, Redis can use up to twice its normal memory while it saves an RDB file or rewrites the AOF, because the forked child shares pages that writes then copy. Redis docs
- With replication, Redis makes RDB saves even with persistence off, unless replication is diskless. Redis docs
-
Redis also advises setting
maxmemorybelow the free memory, to leave room for its overhead and fragmentation: with 10 GB free, set it to 8 or 9 GB. Redis docs
So the calculator provisions the worst case, 2 × maxmemory.
Assumption
Without persistence or replication, the note suggests about 1.25 × maxmemory, which is Redis's 10-to-8 ratio
turned around.
Assumption
04 What the calculator writes
maxmemory 819mb
maxmemory-policy allkeys-lru
-
Both lines go in
redis.conf, or at runtime withCONFIG SET maxmemory 819mb, as the eviction guide shows. Redis docs -
CONFIG SETtakes effect from the next command, andCONFIG REWRITEwrites the running configuration back to theredis.confthe server started with. Redis docs
05 Every warning, and why
| Message about | Shown when | Basis |
|---|---|---|
| Peak below average error | The peak you entered is lower than the average | Impossible with real samples; it usually means two different series. See the sizing model. |
06 What to paste
redis_memory_used_bytes{instance="redis:6379"}
-
redis_exporter publishes
INFO'sused_memoryasredis_memory_used_bytes. redis_exporter source -
Without it, sample
redis-cli INFO memoryand paste theused_memory:lines; the calculator reads them as bytes.
07 All assumptions in one place
Besides the margins of the shared sizing model:
Our default: a value we chose. Our reading: how we read documentation that isn't explicit. About your setup: something we take for granted about your data or cluster.
| Assumption | Kind | Why | If it doesn't hold |
|---|---|---|---|
| Provision 2 × maxmemory ↩ | Our default | Redis documents up to 2× during RDB saves and AOF rewrites | A read-mostly Redis copies fewer pages during a fork and needs less. |
| About 1.25 × maxmemory without persistence or replication ↩ | Our reading | Redis's example sets maxmemory to 8 of 10 GB free | With 9 of 10 GB, the ratio is 1.11; more fragmentation needs more. |
maxmemory from peak used_memory ↩ | Our default | used_memory is the figure INFO and exporters give | It includes overhead beyond the data, so maxmemory comes out a little high. |
| This Redis is a cache ↩ | About your setup | That's what an eviction policy is for | For data you can't lose, use noeviction so writes fail at the limit instead. |
Values you can change
The calculator’s Advanced: margins and defaults section, closed by default, lets you replace these values when your setup differs. Each field’s “?” says how it moves the result; a value outside the range is used at its nearest end, and “Reset to defaults” puts them all back.
| Value | Default | Range | Where the default comes from |
|---|---|---|---|
| Request margin | from the profile | 0–200% | MemoryLimit’s default, from sensitivity, workload type and environment (sizing model); sizes the floor of maxmemory |
| Limit margin | from the profile | 0–200% | MemoryLimit’s default, from sensitivity, workload type and environment (sizing model); sizes maxmemory |
| Provisioning factor | 2 × maxmemory | 1–3× | Redis documents up to 2× during RDB saves and AOF rewrites, assumption 1; about 1.25× without persistence or replication, assumption 2 |
08 References
- Key eviction —
maxmemory, the policies, and buffers not counted. - Redis administration — up to 2× during saves, setting
maxmemorybelow free memory, replication. - redis.conf — memory units.
CONFIG SETandCONFIG REWRITE.- redis_exporter source —
redis_memory_used_bytes.