mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #1990] [RFC]: Native SSD KV Storage Backend for Mooncake Store #552
Labels
No labels
ascend
auto-closed
bug
bug
CI/Build
Common
documentation
enhancement
feature request
good first issue
help wanted
high priority
MetaX
nightly-failure
pull-request
PyTorch Backend
question
RFC
Roadmap
stale
Store
Tests
Transfer Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/Mooncake#552
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kangyifei on GitHub (Apr 27, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/1990
1. Introduction
We would like to propose integrating SSD KV Engine into Mooncake Store as a new SSD storage backend. SSD KV Engine is a high-performance, SSD-optimized single-node KV engine specifically designed for KV Cache offload workloads. It will be released as an independent open-source repository and jointly compiled with Mooncake Store as a static library.
The integration is implemented as
SsdKvStorageBackend, a concrete implementation of Mooncake'sStorageBackendInterface. It plugs seamlessly into the existingFileStorage/FileBackendpipeline, requiring no changes to upper-layer application code.The goal is to give Mooncake Store a low-cost, large-capacity SSD tier that complements DRAM-based storage without introducing remote target mounting or mixed-layer placement complexity.
The initial implementation focuses on single-node KV Cache offload. Cluster-wide placement, replication, and rebalancing remain the responsibility of Mooncake Store rather than the engine itself.
2. Background and Motivation
As long-context scenarios proliferate — multi-turn conversation, coding assistants, document understanding — the size of KV Caches continues to expand. DRAM is both expensive and capacity-constrained, making it insufficient to satisfy the demands of large-scale KV Cache storage.
SSD offers an effective cost/capacity tradeoff. However, Mooncake's existing storage backends (
FilePerKeyBackend,BucketBackend,OffsetAllocatorBackend) all operate through the filesystem layer — each offload/load translates into file creation, open, write/read, and close syscalls. This per-file overhead becomes a bottleneck when KV Cache workloads demand high-frequency, small-granularity I/O. Furthermore, filesystem-based backends provide no built-in persistence semantics beyond what the OS page cache offers, requiring external mechanisms to guarantee data durability.Meanwhile, existing community SSD approaches introduce additional operational friction:
SSD KV Engine addresses all of the above:
Put/Get/Delbatch APIs that bypass the filesystem entirely. Data is written to and read from the block device through an optimized I/O path, eliminating per-file syscall overhead and delivering significantly higher throughput than filesystem-based backends.3. Technical Design
3.1 Architecture Overview
The integration follows Mooncake's existing storage backend abstraction.
SsdKvStorageBackendsits behindStorageBackendInterfaceand forwards operations to SSD KV Engine.SSD KV Engine is both a standalone application and a linkable library. When built with Mooncake, it is compiled as a static library and linked directly — there is no runtime subprocess or network hop between
SsdKvStorageBackendand the engine.3.2 SSD KV Engine Interface
SSD KV Engine exposes the following interfaces to upper layers:
batch_put(batch_ctx, batch_size, iter_fn, cpl_fn)batch_get(batch_ctx, batch_size, iter_fn, cpl_fn)batch_del(batch_ctx, batch_size, iter_fn, cpl_fn)batch_scan(scan_ctx, iter_fn)iter_fnfor each entrycount()/size()/capacity()All batch APIs follow an iterator / completion-callback model:
iter_fn(batch_ctx, index, &key, &value, &value_size)— called by the engine to pull the next item from the caller's buffer.cpl_fn(batch_ctx, index, status)— called by the engine when each item's I/O completes.This design decouples data supply from result handling, allowing
SsdKvStorageBackendto feed slices and collect results asynchronously.3.3 Key and Value Flexibility
SSD KV Engine accepts variable-length keys and variable-length values. Internally, the engine hashes incoming keys into fixed-width representations for O(1) index lookup, so callers can pass arbitrary-length string paths directly without external mapping. Values of any size are handled natively by the engine.
3.4 StorageBackendInterface Integration
SsdKvStorageBackendimplementsStorageBackendInterfaceto bridge Mooncake's FileStorage pipeline with SSD KV Engine:Init()initializes the engine runtime and opens the underlying block device.BatchOffload()passes string paths and data directly to enginebatch_put; the engine handles key hashing internally.BatchLoad()passes paths to enginebatch_getand fills the output buffers.IsExist()checks whether a key exists in the engine.IsEnableOffloading()always returnstrue— the engine manages capacity internally via LRU eviction, so it is always ready to accept new writes.ScanMeta()delegates to the engine's built-in key enumeration interface and invokes the provided callback for each stored entry.Backend registration:
StorageBackendType::kSsdKvis added.CreateStorageBackend()factory instantiatesSsdKvStorageBackendwhen the type matches.MOONCAKE_STORAGE_BACKEND_TYPE=ssd_kv_storage_backend.3.5 Build Integration
USE_SSD_KV_BACKENDguards all SSD KV Engine code. When disabled, zero additional compilation or runtime overhead is added to Mooncake.SSD_KV_ENGINE_PATH.4. Compatibility
SsdKvStorageBackendimplementsStorageBackendInterfacein full. All callers that useFileStoragecontinue to work without modification.BucketBackend,FilePerKeyBackend,OffsetAllocatorBackend— are completely unaffected.USE_SSD_KV_BACKENDis off, no symbols, headers, or link dependencies from SSD KV Engine are included.5. Alternatives Considered
SSD pool over NVMe-oF
This approach expands KV Cache capacity using remote NVMe-oF targets. However, it requires users to discover and mount remote NVMe-oF targets manually before the service starts, and the underlying SPDK-based I/O framework relies on CPU core affinity, which competes with inference engines for cores. In contrast, SSD KV Engine is built on standard pthreads without any core pinning, coexisting naturally with inference engines. Operational complexity is higher than a locally-linked library approach.
Standards-aligned NVMe KV backend
This design introduces a full backend + connector + executor three-layer stack with a dedicated control-plane service for device state and cleanup orchestration. While architecturally clean, the added complexity and the control-plane dependency raise the barrier for single-node or low-ops deployments. The SSD KV approach achieves the same SSD offload goal with a simpler integration path.
Mixed SegmentManager for SSD and memory
Managing SSD and DRAM segments in the same
SegmentManagermakes replica placement and access latency non-deterministic — callers cannot reliably predict whether a given read will hit DRAM or SSD. Keeping SSD as a dedicatedStorageBackendbehindFileStoragepreserves explicit tiering semantics.SSD KV Engine takes the simplest path that is still correct and efficient: a self-contained static library with a single-file integration point via
StorageBackendInterface. We believe this is a natural addition to the Mooncake storage backend ecosystem and look forward to community feedback.Before submitting a new issue...
@stmatengss commented on GitHub (Apr 29, 2026):
Please consider this RFC: #1957
@github-actions[bot] commented on GitHub (Jul 29, 2026):
This issue has had no activity for 90 days and will be closed in 7 days if there is no further activity. Please comment or react if it should stay open.
@github-actions[bot] commented on GitHub (Aug 6, 2026):
Closing due to 3 months of inactivity. If this is still relevant, please comment and we can reopen.