Scrivio Interview library
ScenarioAdvanced6 min read · updated 13 November 2026

A shared Redis fleet is at 85 percent of maxmemory on most nodes, and the budget for new nodes is frozen for two quarters. A platform engineer proposes raising zset-max-listpack-entries and hash-max-listpack-entries to 1024 everywhere to save memory.

How do you evaluate this proposal and roll it out, if at all?

I would not apply it everywhere. First I would find where memory actually goes, because the change only helps hashes and sorted sets whose size falls between 128 and 1,024 entries. Then I would benchmark real workloads at both settings, since listpack operations scan linearly and raise CPU and p99, and roll it out per instance class, only on memory-bound, read-light instances, alongside cheaper wins such as missing TTLs, dead key patterns and compact serialization, knowing that savings arrive only as keys are rewritten.

Why this question is asked

A configuration change that promises to save memory across a whole fleet, with a frozen budget, is tempting, and a senior engineer is expected to slow it down just enough to make it safe. Interviewers ask this because it combines internals (what the setting really does), measurement and change management. In this answer, we will see what the setting changes, measure who would benefit, look at the CPU cost, design a benchmark, plan a staged rollout with a rollback, and compare it with cheaper wins.

1What the Setting Changes

Hashes and sorted sets are stored as listpacks, compact byte arrays, while they have at most 128 entries and every element is at most 64 bytes. Above that they become a hashtable, or for sorted sets a skiplist plus a hashtable, which cost several times more memory per entry. Raising hash-max-listpack-entries and zset-max-listpack-entries to 1,024 lets values with 129 to 1,024 entries stay compact.

That last sentence is the key to the evaluation. Values below 128 entries are already compact and gain nothing. Values above 1,024 entries convert anyway. And values whose elements exceed the 64-byte value limit convert regardless of the entry count. Only keys in that middle band benefit.

2Finding Where the Memory Goes

So the first step is data, per instance. We take an RDB file from a replica of each cluster and analyse it offline, which gives key counts by pattern, encodings, element counts and sizes without touching production. Sampled MEMORY USAGE on a replica can fill gaps.

Often the result is surprising. On one cluster, 70 percent of memory may be millions of small string keys, where the change does nothing. On another, sorted sets of 200 to 800 members holding leaderboards may be half the memory, and there the change could save a lot. That tells us where the proposal is worth testing at all.

3The Cost: CPU and Latency

A listpack is scanned from one end. On a skiplist, ZRANK or ZRANGEBYSCORE costs O(log N), about 10 steps for 1,000 members. On a 1,000-entry listpack, the same command may walk hundreds of entries, and ZADD may need to reallocate and shift the whole array to insert in order. HGET on a 1,000-field listpack also scans, where a hashtable goes straight to the field.

Each call is still only microseconds, but on a busy primary microseconds add up. If an instance runs 50,000 ZADD and ZRANGEBYSCORE calls per second on these keys and each becomes five times slower, the main thread may go from 40 to 70 percent, and p99 rises for every client on that instance, not only for the leaderboard.

What a 1,000-entry value costs in each encoding
listpack (limit 1024)hashtable / skiplist (limit 128)
Memory per entrya few bytes plus datatens of bytes of overhead
HGET / ZSCORElinear scanO(1) lookup
ZADD / ZRANKscan, may reallocate arrayO(log N)
Best fitmemory-bound, read-lightCPU-sensitive, write-heavy
The same key is cheaper in memory and more expensive in CPU after the change.

4Benchmarking on a Copy

We restore a recent RDB into two test instances, one with the old limits and one with 1,024, and replay the real command mix for that instance class, ideally captured traffic or a load generator driven by commandstats. For each we record used_memory, main-thread CPU, and p50, p99 and p999 per command from INFO latencystats.

Remember that the saving does not appear just by loading old data unless the loader rebuilds the values; restoring from RDB does create values fresh with the new limits, which is what we want for the test. The decision then becomes concrete: on instance class A we save 18 percent memory and p99 rises from 0.3 to 0.35 ms, which is acceptable; on class B we save 3 percent and p99 doubles, which is not.

5Rolling It Out, Class by Class

Settings should be set per instance class, not fleet-wide. We start with one memory-bound, read-light class, apply the change with CONFIG SET and in the configuration files, on replicas first if possible, and watch CPU and latency for a week before the next class.

We also tell the business the truth about timing. The setting applies when keys are created or converted. Existing hashtables and skiplists do not shrink back, so the saving arrives slowly as keys expire and are rewritten, or quickly if we fail over to a replica that reloaded the data with the new limits. In the budget plan, that difference matters.

Step throughStaged rollout for one instance class
  1. Offline RDB analysisshare of memory in 129-1024 entry values
  2. Worth more than ~10 percent?
    YesbenchmarkNoskip this class
  3. Benchmark on restored copymemory, CPU, p99 per command
  4. Latency within budget?
    YesCONFIG SET on one instanceNoskip this class
  5. Watch a weekCPU, latencystats, used_memory
  6. Extend to the classand record the setting in config management

6 steps in order. Play them, or step through them one at a time.

6The Cheaper Wins First

Before any of this, the fleet usually has easier savings. Keys with no TTL that nobody reads any more, found by the same RDB analysis and an idle-time scan. Whole key patterns from retired features. Values serialized with JDK serialization, which can be three to five times larger than JSON or a binary format, and large values that compress well. Each of these saves memory with no CPU cost to other clients. After taking them, we may find that the encoding change is no longer needed, or only on one or two classes.

7Follow-up questions

How would you roll back if p99 rose after the change?

Set the limits back to 128 with CONFIG SET, which stops new values from being created as large listpacks. Existing large listpacks stay as they are, but each one converts to a hashtable or skiplist the next time an entry is added to it, because it is already above the restored limit; to return quickly to the old performance we fail over to a replica that loads the data with the old limits, or rewrite the hot keys. Because we rolled out one class at a time, only that class needs this.

Is there any risk in setting the limits per instance rather than fleet-wide?

The risk is configuration drift, where nobody knows why one class differs. We manage it by keeping the setting in configuration management with a comment that links to the benchmark, and by including encoding settings in the regular fleet report.

Would Redis Cluster change the evaluation?

Not the mechanics, since encodings are per key. It does mean the benchmark must reflect the busiest shard, because a hot key on one node feels the CPU cost most.

8Conclusion

In this answer, we saw that raising the listpack limits only helps values between the old and new entry counts, so we first measure where memory goes with offline RDB analysis. The cost is linear-scan CPU and higher p99 for every client, so we benchmark real workloads on restored copies and roll out per instance class with a week of observation and a clear rollback. Savings arrive slowly because existing keys do not shrink back, and cheaper wins such as TTLs, dead keys and compact serialization should come first.

What to say in the interviewAbout 80 seconds aloud

Open with

I would treat it as a per-class change, not a fleet-wide one. First I would find where the memory goes, using offline RDB analysis from replicas to get key counts by pattern, encodings and element counts, because raising the limits to 1,024 only helps hashes and sorted sets with between 129 and 1,024 entries and small elements; everything else is unchanged.

Then, if they want more

Then the cost: listpacks scan linearly, so ZADD, ZRANK, ZRANGEBYSCORE and HGET on a thousand-entry listpack are much slower than on a skiplist or hashtable, and on a busy primary that raises p99 for every client.

So I would restore an RDB into two test instances, one per setting, replay the real command mix, and compare memory, CPU and latency percentiles. Where the saving is real and latency stays within budget, typically memory-bound, read-light instances, I apply it one class at a time, watch for a week and keep a rollback.

I would also be clear that existing hashtables and skiplists do not shrink back, so savings come slowly unless data is rewritten or reloaded. And before any of this I would take the cheaper wins: TTLs where missing, dead key patterns, compact serialization instead of JDK serialization, and compression of large values.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "How do you evaluate this proposal and roll it out, if at all?": https://scrivio-interview-library.netlify.app/databases/redis-internals/fb762b23e9/