Introducing the Valkey Large Object Module: As Fast as Your Hardware
Large objects show up in a wide range of applications, from video and audio files to, more recently, the KV attention states of large language models (LLMs). An LLM reads the whole prompt before it answers. For every token, at every layer, it computes a key vector and a value vector that later tokens use to decide what to pay attention to. Those saved vectors are the KV cache. If a later request starts with the same text, such as a shared system prompt, a long document or the earlier turns of a conversation, the inference engine can load the saved KV cache instead of computing it again, which saves GPU time and shortens the time to the first token.
GPU memory is too small to keep every cache, so inference stacks keep them in tiers: GPU memory, then the host's memory, then a shared store that every GPU server can read, managed by tools such as LMCache. Valkey can be that shared store, and a Valkey cluster scales its capacity independently of the GPU servers, as KV caching on Valkey shows for a fleet of GPU servers.
LMCache splits a prompt into chunks, 256 tokens by default, and stores each chunk as one object. The size depends on the model and the chunk size:
| Model | Cache per token | 256-token chunk | 2,048-token chunk | 256-token chunk, per GPU across 8 GPUs | 2,048-token chunk, per GPU across 8 GPUs |
|---|---|---|---|---|---|
| Kimi K2.7-Code (FP8) | 34.3 KiB | 8.6 MiB | 69 MiB | 8.6 MiB | 69 MiB |
| Qwen3-235B-A22B (FP8) | 94 KiB | 23.5 MiB | 188 MiB | 5.9 MiB | 47 MiB |
| Mistral-Medium-3.5-128B (FP8) | 176 KiB | 44 MiB | 352 MiB | 5.5 MiB | 44 MiB |
Larger chunks mean fewer, bigger objects per prompt, and a cache hit has to move many of them quickly. The Valkey Large Object module is built for that. In our benchmark, one node sustained 372-399 Gbps of reads and writes at every object size. This allows all the models in the table above to set up distributed KV caching workloads that retrieve KV objects with a median latency under 1 ms for 1 MiB objects and about 10 ms for 32 and 64 MiB objects. However, the module is not limited to KV caching; it efficiently stores large binary values.
This is the first of three posts on distributed KV caching with Valkey. It covers what changes in in-memory key-value datastores when values reach hundreds of megabytes, and how the Valkey Large Object module improves performance for such large objects.
What changes when values reach hundreds of megabytes
Valkey is built for small values, typically a few hundred bytes. Commands run on the main thread while other clients wait, and every byte goes through the TCP stack and the server's network buffers. With small values, the Valkey CPU is typically not the bottleneck as it's able to serve each request quickly.
We measured stock Valkey 9.2.0 over TCP, with every value held in DRAM, on one i8ge.48xlarge (maxmemory 640gb, allkeys-lru, 8 I/O threads).
Throughput fell from 305 Gbps at 1 MiB to 89 Gbps at 500 MiB, and a PING from another connection took 1.2-48 ms at p99 and up to 440 ms.
Table 1: Performance of Valkey without the Large Object module
| Object size (MiB) | Total Gbps (GET + SET) | GET p50 / p99 (ms) | SET p50 / p99 (ms) | PING p99 / max (ms) | Evictions per second |
|---|---|---|---|---|---|
| 1 | 305.3 (144.5 + 160.8) | 1.0 / 1.6 | 1.4 / 3.5 | 1.2 / 440 | 18,795 |
| 8 | 213.4 (147.9 + 65.5) | 13.8 / 22.3 | 32.0 / 52.2 | 10.4 / 228 | 955 |
| 32 | 201.9 (136.7 + 65.2) | 46.1 / 64.7 | 83.4 / 208 | 17.4 / 239 | 238 |
| 64 | 171.4 (110.2 + 61.2) | 77.1 / 105 | 134 / 189 | 19.5 / 226 | 112 |
| 256 | 94.2 (47.6 + 46.6) | 352 / 396 | 373 / 430 | 37.6 / 97 | 21 |
| 500 | 89.1 (44.1 + 45.0) | 751 / 973 | 751 / 830 | 48.5 / 253 | 11 |
The workload: Two c8gn.16xlarge clients drove it with cachecannon and a 10-second request timeout, using an equal number of GET and SET connections per client: 16 each at 1 and 8 MiB, 12 each at 32 MiB, 8 each at 64 MiB, and 4 each at 256 and 500 MiB.
GETs read a 64 GiB hot set that was filled beforehand, so almost every GET finds its key, and SETs always write new keys, so none overwrites an existing value.
The SETs first filled memory to the limit, and the measurement then ran with the server at the limit and evicting continuously.
A separate connection sent a PING every 10 ms to show how long an unrelated small command waits.
What the module is
The Valkey Large Object module is a Valkey module written in Rust that adds a data type and commands optimized for large binary values. It needs Valkey 8.0 or later on Linux.
Figure 1: How the module handles a GET or SET
Data type. A Large Object data type holds a small descriptor, not the object's bytes: an object ID, the length and a CRC32C checksum.
The bytes live in the module's segments or in a file, depending on the operating mode.
An object can be up to largeobj.max-object-size (512 MiB by default, configurable), and in Dram mode it must fit in one segment.
Like a String, this is a single value data type.
Engine. Every GET and SET blocks only the client that issues the command, in every storage and transport mode.
The module moves the data on its own worker threads (8 by default, largeobj.worker-threads) while the Valkey main thread keeps serving everyone else.
Objects are streamed in chunks (1 MiB by default, largeobj.chunk-size), up to 64 at a time (largeobj.max-buffers-per-op), and each chunk moves on as soon as its source has produced it, so network and disk transfers overlap.
In Tiered mode the chunks pass through a bounded window of reused staging buffers, so a transfer never allocates the whole object.
Memory. Data sent or received over EFA must sit in memory registered with the EFA network card, and registering is too slow to do on every transfer.
So the module allocates memory from Valkey in large segments (1 GiB each by default, largeobj.segment-size), which count toward used_memory and maxmemory, and registers each segment when it is created.
In Tiered mode the segments are registered with io_uring as well, for performance, so the kernel pins their pages once instead of on every disk read and write, and one buffer serves the network and the disk without a copy.
Inside each segment, the module's own allocator hands out exact-sized, 4 KiB-aligned slots.
The DRAM cache pool starts with one segment and adds more as it fills, up to maxmemory.
In Dram mode it holds every object, and in Tiered mode it acts as a read cache, next to the fixed-size disk staging segment pool described below.
Disk. In Tiered mode every object is a file on block storage, such as local NVMe or network-attached block storage like Amazon EBS, and DRAM is a read cache.
The module reads and writes the files with direct I/O through io_uring, so object bytes skip the operating system's page cache.
Writes and cache misses pass through the fixed-size disk staging segment pool, which totals largeobj.disk-staging-size of DRAM.
An object is copied into the DRAM cache on its first read by default, and when the cache is full, less frequently used copies are dropped while the objects stay on disk.
When the disk limit or maxmemory is reached, a write evicts the least recently used large objects that maxmemory-policy allows, as core Valkey does.
Transport. The RDMA commands use libfabric.
A client sends BLOB.RDMA_HELLO once per connection with its libfabric endpoint address, and the reply lists the server's addresses.
Each BLOB.RDMA_GET or BLOB.RDMA_SET then lists one or more remote addresses in the client's registered memory, each with its memory key and length, in one registered region or several, and the server writes to or reads from them directly.
The object bytes never travel on the Valkey TCP connection, which carries only the command and the transfer details.
The server starts every transfer, so a client never gets access to server memory.
BLOB.TCP_SET and BLOB.TCP_GET carry the bytes on the normal connection and work with any client.
The default EfaDirect provider needs EFA hardware.
Integrity. BLOB.RDMA_SET can send a CRC32C checksum that the server verifies, and BLOB.RDMA_GET returns the stored checksum and the length so the client can verify what it received.
How fast it runs
The module kept 372-399 Gbps of combined GET and SET throughput at every object size from 1 MiB to 500 MiB, 1.2x to 4.2x stock Valkey, while a PING to the same server stayed under 0.4 ms at p99.
These are results from one i8ge.48xlarge server in Tiered mode over RDMA with AWS Elastic Fabric Adapter (EFA), measured at the disk limit where every SET evicts the oldest objects.
Figure 2: Combined GET and SET throughput, stock Valkey and the module
Table 2: Performance improvements with the Large Object module
Each cell shows stock Valkey → the module.
| Object size (MiB) | Total Gbps (GET + SET) | GET p50 (ms) | GET p99 (ms) | SET p50 (ms) | SET p99 (ms) | PING p99 (ms) |
|---|---|---|---|---|---|---|
| 1 | 305 → 372 (1.2x) | 1.0 → 1.3 | 1.6 → 2.1 | 1.4 → 1.5 | 3.5 → 2.8 | 1.2 → 0.2 |
| 8 | 213 → 399 (1.9x) | 13.8 → 10.6 | 22.3 → 15.2 | 32.0 → 10.8 | 52.2 → 16.2 | 10.4 → 0.2 |
| 32 | 202 → 389 (1.9x) | 46.1 → 31.5 | 64.7 → 37.5 | 83.4 → 34.3 | 208 → 41.2 | 17.4 → 0.4 |
| 64 | 171 → 378 (2.2x) | 77.1 → 43.8 | 105 → 54.5 | 134 → 45.6 | 189 → 56.1 | 19.5 → 0.4 |
| 256 | 94 → 372 (4.0x) | 352 → 88.6 | 396 → 101 | 373 → 95.4 | 430 → 105 | 37.6 → 0.3 |
| 500 | 89 → 372 (4.2x) | 751 → 178 | 973 → 193 | 751 → 185 | 830 → 195 | 48.5 → 0.3 |
The results:
- The module moved 1.9x to 4.2x the throughput of stock Valkey from 8 MiB up, and 1.2x at 1 MiB. Its total stayed between 372 and 399 Gbps at every size, while stock Valkey's fell from 305 Gbps at 1 MiB to 89 Gbps at 500 MiB.
- A
PINGfrom a separate client waited at most 0.4 ms at p99 with the module, against 1.2-48 ms with stock Valkey. - From 8 MiB up the module evicted 2.8 to 3.9 times faster than stock Valkey (2,670 against 955 per second at 8 MiB), because it accepted that many more
SETs, and it rejected none at any size. - On the same instance type, the module node held 108 TB on NVMe, about 150 times the 640 GiB that stock Valkey held in DRAM.
- With the DRAM cache turned off, so that every
GETreads from NVMe,GETs reached the same 215-216 Gbps as cache hits from DRAM, because the 16 local NVMe drives can read faster than the network can carry. The cache matters when storage is the limit, for example on network-attached block storage, where reads and writes share one bandwidth limit: everyGETserved from DRAM leaves that bandwidth toSETs.
The workload: The server had a 108 TB disk limit on 16 instance-store NVMe drives striped under XFS.
Two c8gn.16xlarge clients drove it over EFA with cachecannon, using the same workload as the stock run: the same number of GET and SET connections per client, GETs over a 64 GiB hot set, and SETs of new keys at the same time.
The run filled the disk first, then ran at the limit.
The stock results come from the earlier section.
It is important to note that the test instances' network and storage bandwidth cap these numbers, so machines with higher limits can go much further.
Table 3 is a separate run at lower concurrency. Each of the two clients ran 4 GET and 4 SET connections at 1 to 32 MiB, 2 and 2 at 64 and 256 MiB, and 1 and 1 at 500 MiB. With fewer requests in flight, the module's latency is lower than in Table 2.
Table 3: Lower latency with the Large Object module and optimal clients
| Object size (MiB) | GET p50 / p99 (ms) | SET p50 / p99 (ms) |
|---|---|---|
| 1 | 0.3 / 0.5 | 0.5 / 0.8 |
| 8 | 2.6 / 3.9 | 3.0 / 4.6 |
| 32 | 10.4 / 13.7 | 11.6 / 15.5 |
| 64 | 10.3 / 13.8 | 13.0 / 17.7 |
| 256 | 41.7 / 49 | 51 / 62 |
| 500 | 59 / 73 | 68 / 82 |
Try it
To read and write your first large object, start with the getting started guide.
It walks you through building the module and running your first commands.
The configuration guide covers storage and monitoring settings, and the use cases show where else the module fits.
Tiered mode expects an XFS file system and Linux 5.1 or later.
The benchmark above ran with this command, on an i8ge.48xlarge with its 16 NVMe drives striped under XFS, and with maxmemory unset so the DRAM cache grew as needed:
valkey-server \
--port 6379 --save '' --appendonly no \
--maxmemory-policy allkeys-lru \
--loadmodule ./target/release/libvalkey_large_object.so \
--largeobj.operating-mode Tiered \
--largeobj.disk-dir /mnt/bigobj-data/lo \
--largeobj.segment-size 1073741824 \
--largeobj.disk-staging-size 17179869184 \
--largeobj.disk-maxmemory 108000000000000 \
--largeobj.fabric-provider EfaDirect
The Valkey Large Object module is open source, and Valkey Large Object 0.1 is available now.
The TCP commands work with any client.
The RDMA commands need a client that implements the libfabric flow; Valkey GLIDE's Python sync client supports them from valkey-glide-sync 2.6.0.
The second post in this series compares Valkey deployments for KV caching, over the network and on the GPU servers themselves, and shows how each performs against other object stores. The third goes deeper into model and inference architectures and how to configure Valkey for your inference setup.
The module was developed with contributions from Karthik Subbarao, Cameron Zack, Neeraj Ramachandran, Anita Ruangrotsakun, Nadav Levanoni, Kenny Chamberlin, Kevin McGehee and Muhammad Ibrahim. Thanks also to everyone who shaped the design, to those who added support for the module in Valkey GLIDE and to those who built the LMCache integration.