Centralized KV Cache Architecture for Disaggregated LLM Inference

    This article explains how to design a disaggregated large language model inference system that treats KV cache as a first-class resource. It covers Prefill and Decode separation, distributed and tiered KV cache pools, request routing, scheduling, high-speed data transfer, reliability, observability, and cloud deployment considerations for high-concurrency, long-context, and cost-sensitive workloads.

    Centralized KV Cache Architecture for Disaggregated LLM Inference

    1. Background and Design Goals

    Large language model inference services typically consist of two stages: Prefill and Decode. Prefill processes the complete input in one pass and generates the key-value cache, or KV cache. It is compute-intensive and benefits significantly from batching. Decode generates output one token at a time, making it memory-bandwidth-intensive and highly sensitive to tail latency.

    Traditional deployments run both stages in the same instance or resource pool. Although this approach is simple, it creates three structural problems:

    1. Resource mismatch: Prefill requires more compute, while Decode depends more heavily on memory bandwidth and cache capacity. Their scaling patterns also differ, so tightly coupled deployment can cause mutual interference.
    2. Cache growth: Long contexts, multi-turn conversations, and retrieval-augmented generation can significantly increase KV cache consumption. GPU memory becomes a hard bottleneck, and insufficient cache reuse leads to repeated computation.
    3. Coarse-grained scheduling: Under high concurrency, long and short requests compete for resources. Long Prefill tasks can block Decode operations and make it difficult to meet both throughput and SLO requirements.

    The goal of system design should therefore extend beyond simply running the model. It should address throughput, cost per token, time to first token, inter-token latency, elastic scaling, and observability.

    The core design principle is to organize the data flow around the KV cache: decouple Prefill and Decode into independent node pools, enable pooled sharing through a distributed KV cache, and connect compute resources with the cache through an independent data transfer layer.

    2. Overall Architecture and Request Workflow

    A complete disaggregated inference system generally consists of a control plane and a data plane.

    The control plane includes the request gateway, global scheduler, metadata service, cache manager, and monitoring and alerting systems. The request gateway handles authentication, rate limiting, and protocol adaptation. The scheduler manages prefix-aware routing, load balancing, and SLO policies. The metadata service maintains block tables, leases, versions, and location indexes. The cache manager performs eviction, prefetching, and quota management.

    The data plane includes the Prefill node pool, Decode node pool, distributed KV cache pool, and high-speed transfer layer. The KV cache pool can be organized into multiple tiers:

    • GPU memory as the hot cache
    • Host memory as the near cache
    • A remote memory pool as the shared cache
    • General-purpose object storage as the cold backup

    The transfer layer moves cache blocks efficiently between compute nodes and cache pools.

    A typical request workflow is as follows:

    1. The request enters the gateway, where the system identifies the tenant, estimates input length, and assigns a priority.
    2. The scheduler calculates the prefix hash and queries cache metadata to determine whether reusable KV cache is available.
    3. On a cache miss, the request is routed to the Prefill node pool. The generated KV cache blocks are written to the cache pool.
    4. A Decode node retrieves the KV cache blocks, establishes a local hot cache, and begins streaming generation.
    5. New blocks are continuously written during generation. Leases and reference counts are updated, and the blocks are demoted or evicted according to policy after the request completes.
    6. The monitoring system collects cache hit rates, transfer latency, queue lengths, and recomputation rates, and feeds this information back into scheduling and scaling decisions.

    The routing and block-fetching logic can be summarized with the following pseudocode:

    1. function handle(request):
    2. prefix = hash(request.prompt)
    3. plan = scheduler.plan(prefix, request.slo, request.tenant)
    4. if cache.metadata.hit(prefix, plan.affinity):
    5. blocks = cache.acquire(prefix, lease=request.ttl)
    6. else:
    7. blocks = prefill_pool.execute(request)
    8. cache.publish(prefix, blocks, version=next_version())
    9. decode_pool.run(request, blocks, prefetch=plan.topology_aware)
    10. cache.release(blocks)

    3. Centralized KV Cache and Cache Pool Design

    Centralizing the KV cache does not simply mean moving the cache to remote storage. The cache should be managed as a first-class data asset.

    Fixed-size blocks are recommended as the basic unit. A block table maps logical blocks to physical locations, while prefix hashing enables reuse across system prompts, multi-turn conversations, and long documents. Each block should maintain a reference count, lease, version number, and tenant label to ensure consistency between Prefill writes and Decode reads.

    Tiered caching must balance hit rates against network costs:

    • GPU memory provides low-latency access for hot data.
    • Host memory stores recently used blocks.
    • A remote memory pool enables sharing across nodes.
    • Object storage provides cold backup and recovery support.

    Eviction can combine LRU, LFU, and prefix-frequency policies. Cost-aware eviction should also consider block size, transfer cost, and tenant quotas to avoid cache thrashing.

    For sensitive data, block-level tenant isolation, access control, and encrypted transmission should be implemented. This helps prevent information leakage caused by cross-tenant cache reuse.

    4. Prefill-Decode Disaggregation and Scheduling

    Independent scaling of the Prefill and Decode node pools is a direct benefit of the disaggregated architecture.

    Prefill can use larger batches to improve compute utilization. Decode should use smaller batches and latency-sensitive scheduling to protect inter-token latency. The scheduler should consider prefix affinity, topology distance, node load, and SLO requirements at the same time.

    Requests with cache hits should preferably be routed to nodes in the same rack or near the relevant cache pool. Long and short requests should be separated into different queues. When the cache pool becomes congested, backpressure, timeouts, and degradation policies should be used to protect the overall system.

    For mixed workloads, it is recommended to introduce admission control and priority queues. Requests with reusable prefixes can be prioritized, while extremely long requests can be split or subject to concurrency limits.

    The scheduling objective should not be local optimization for a single request. Instead, it should balance global throughput, tail latency, and cost.

    5. Transfer Engine and Reliability

    The transfer layer should support block-level batch transfers, zero-copy operations, integrity checks, retries, and multiple transport protocols.

    Within a node, shared memory can reduce copying. Between nodes, high-speed transfer technologies such as remote direct memory access can be used. For cross-region scenarios, the system can fall back to general-purpose object storage.

    Data transfer and computation should overlap whenever possible. For example, Decode can prefetch subsequent blocks while generating the current block. Double buffering and pipelining can help hide transfer latency.

    For reliability:

    • A failed Prefill operation can be recomputed.
    • A failed Decode operation can recover from persisted cache blocks.
    • Replicas, lease renewal, and metadata reconstruction can reduce the impact of cache-node failures.
    • The metadata service should be deployed with sharding and multiple replicas.

    Important observability metrics include cache hit rate, block transfer latency, recomputation rate, queue length, time to first token, and P99 inter-token latency.

    6. Deployment Practices and Future Evolution

    When deploying in the cloud, general-purpose object storage, container platforms, logging services, and monitoring and alerting capabilities from providers such as Baidu AI Cloud can support cold caching, elastic scaling, and observability. Specific interfaces and quotas should be verified against the target environment.

    Performance evaluation should use workload testing focused on:

    • Throughput
    • Latency
    • Cache hit rate
    • Resource utilization
    • Cost per token

    Testing should compare different scenarios based on the proportion of long-context requests, prefix reuse rate, and concurrency level.

    Future development may focus on new memory interconnect technologies, hardware offload, standardized cache interfaces, and decoupled integration with upper-layer inference frameworks.

    Overall, a KV-cache-centered disaggregated architecture separates compute, caching, data transfer, and scheduling into modules that can evolve independently. This makes the architecture well suited to high-concurrency, long-context, and cost-sensitive LLM inference workloads.