Skip to main contentClaim $5 in free credit — one-time, per account. Claim $5 free
Krova CloudKrova Cloud
Database Hosting

Valkey 9.2 Sorted Sets: Measure Your Dataset’s Memory

Valkey 9.2 replaces the large sorted-set skiplist with a B+ tree. Compare encoding, sampled key memory, server RSS and application results using your own dataset.

RB
Rohit Bhadani6 min read
Share
Database Hosting cover with Valkey 9.2 Sorted Sets, Measure the Memory, a practical subtitle, and a frosted-glass database linked to branching member cards and a memory chip.

Valkey 9.2.0, whose release page is dated 19 November 2026, changes the representation of large sorted sets. If you operate a leaderboard or ranked queue, it’s a useful reason to revisit your memory measurements. Start with a matched dataset comparison, then check the whole server and application before making a capacity decision.

Imagine a leaderboard that has grown steadily since launch. The application still works, but its database now occupies enough RAM to make the next VM size a real question. You read about the new B+ tree and wonder whether upgrading could change that decision. The answer depends on which data structure your keys actually use and how much of the server’s footprint those keys explain.

The leaderboard is hypothetical. This is a proposed rehearsal for Valkey you manage yourself, including inside a Krova Cube. No benchmark was run for this article, and no memory saving or smaller VM is promised.

Check that your dataset exercises the change

The 9.2 release notes say large sorted sets now use a B+ tree and report btree through OBJECT ENCODING, replacing the earlier skiplist representation. Small sorted sets can use a compact listpack encoding instead. That distinction belongs in your test record.

Upstream’s technical explanation, dated 16 November, describes how the new structure groups entries into nodes rather than keeping one separately allocated skiplist node per member. Its benchmark is evidence about upstream’s test conditions. Your member lengths, cardinalities and write patterns still need their own comparison.

For the imagined leaderboard, a tiny development fixture may remain a listpack and miss the large-set path entirely. Choose representative small and large keys, including the sizes that matter during normal growth. Keep the same member names, scores and key names on both sides of the comparison; comparing a short synthetic identifier with your application’s longer identifier would change the question.

Build two comparable rehearsal runs

Use isolated copies of representative data, with one run on your existing supported version and another on 9.2. Keep the VM resources, allocator/build choices, relevant configuration and workload inputs comparable. Record any difference you cannot hold constant. Confirm a supported restoration or fixture-loading procedure for each version; don’t assume a newer data file can be loaded by an older server.

Keep these instances separate from production clients and side effects. Use your normal authorized CLI connection. The examples below assume an isolated local rehearsal instance at 127.0.0.1:6379; adapt the connection options to your authenticated setup and replace the key with a known rehearsal sorted set.

TZ=Asia/Kolkata date -Is
valkey-cli -h 127.0.0.1 -p 6379 INFO server
valkey-cli -h 127.0.0.1 -p 6379 OBJECT ENCODING leaderboard:rehearsal
valkey-cli -h 127.0.0.1 -p 6379 ZCARD leaderboard:rehearsal
valkey-cli -h 127.0.0.1 -p 6379 MEMORY USAGE leaderboard:rehearsal SAMPLES 5

OBJECT ENCODING reports representation, while ZCARD reports the number of members. Retain the server version and these observations together. If the baseline says skiplist and 9.2 says btree, you have observed the representation boundary you intended to examine. If both say listpack, describe that comparison accurately rather than attributing it to the new large-set tree.

MEMORY USAGE reports allocations for the key, value and administrative overhead. For nested values, sampling estimates the total; the default sample count is five. Keep the sampling choice consistent and label the result as an estimate. A null reply means the key is absent, while an access error means the observation failed. Neither is a zero-byte result.

For a present, non-empty set, divide the reported bytes by ZCARD to obtain an estimated total bytes per member for that key. This includes more than tree-node overhead, so give the metric that full name. Check that the dataset stayed unchanged while collecting the readings. Don’t divide by zero or compare keys that expired between commands.

Repeat the workload that changes the shape

A freshly loaded leaderboard is only one phase. In a separate controlled rehearsal, replay the application’s representative score updates, insertions, removals and reads. Record the input sequence and concurrency so the second version receives comparable work. This is especially useful when a key grows substantially and then shrinks.

Check correctness alongside memory. For a known rehearsal key, a bounded result inspection can help:

valkey-cli -h 127.0.0.1 -p 6379 ZRANGE leaderboard:rehearsal 0 9 REV WITHSCORES

The ZRANGE reference documents rank ranges, reverse ordering and scores. Compare the expected members and scores using your application’s tests, including how it handles ties and removals. A ten-member inspection is a useful probe; it cannot establish correctness for every operation or the whole dataset.

Also retain application latency, throughput and errors under the same workload. A memory improvement that comes with an unacceptable application result does not meet the leaderboard’s operating requirement. Choose those acceptance limits before looking at the outcome so a promising memory number cannot quietly redefine success.

Move from key allocations to server memory

valkey-cli -h 127.0.0.1 -p 6379 INFO memory

The INFO documentation distinguishes used_memory, memory allocated through Valkey’s allocator, from used_memory_rss, the process’s resident memory as seen by the operating system. Collect them at matching workload phases. Summing selected key estimates won’t account for every server allocation, client buffer or allocator effect.

Keep a measurement ladder in the comparison:

ObservationDecision it supports
Encoding and member countWhether comparable keys exercise the intended representation
Sampled key bytes and estimated total bytes per memberHow those keys’ allocations differ under the stated method
Server allocated memory and RSSWhether the key-level difference carries through to the process footprint
Guest headroom and application results through busy phasesWhether a particular VM configuration meets the workload’s needs

If the large keys use fewer estimated bytes but RSS barely changes, retain both findings and investigate the rest of the footprint. Don’t relabel one as the other. If only small listpack keys dominate your workload, a large-set result from elsewhere offers limited evidence for your sizing decision.

Make the upgrade and sizing decisions separately

First establish that the candidate version can load the intended data, complete the application workload and meet its operating limits. Follow the full release notes and your normal upgrade process; this article evaluates one representation change, not every compatibility or operational change in 9.2. Keep a verified recovery path for the existing deployment.

Then assess capacity across startup, steady traffic and your configured persistence or replication activity. Avoid changing the Valkey version, memory limit and VM size in one step. Otherwise, an improvement or regression becomes harder to explain.

Krova’s Linux VM memory guide covers the separate guest-headroom check. If the service is slow rather than short of memory, the Linux load diagnostic helps identify what is waiting before choosing another resource.

For the hypothetical leaderboard, the useful deliverable is a comparison you can repeat: dataset and versions, observed encodings, sampling method, key and server readings, workload sequence, application outcomes and remaining limits. That can justify an upgrade or another test. A smaller Cube becomes a separate, measured decision.

Size a Cube around your database workload

Explore self-managed Linux compute, then use representative database and application measurements to choose CPU, RAM and disk.

Creation context: This AI-assisted article uses the linked primary sources checked on 23 November 2026. The leaderboard, commands and rehearsal are illustrative and were not executed. No personal benchmark, customer saving or human review by the bylined author is claimed. The cover is an AI-generated conceptual illustration.

For AI agents:llms.txtsitemap

Related posts