cache-indexer:基于 vLLM 生态的 KVCache 索引管理服务

提供AI推理场景中的全局KV Cache管理能力

Branch8Tags0

cache-indexer

Project Introduction

Cache Indexer is an index service for managing vLLM server cluster KV Cache storage information. It stores and matches token sequences through a multi-way tree structure, helping the routing layer quickly select the best inference server nodes, thereby improving KV Cache reuse rate and inference efficiency.

Core Functions

  • KV Cache Index Management: Uses multi-way tree structure to store KV Cache information of each vLLM server, supporting efficient token sequence matching.
  • Cache Matching Sorting: Provides /match_sort HTTP API, calculates cache matching rate of each server and sorts in descending order of matching rate, used for routing scheduling decisions.
  • K8s Service Discovery: Automatically discovers vLLM server Pods in Kubernetes cluster, supporting dynamic scaling.
  • Real-time Cache Synchronization: Receives cache change events of each vLLM server in real-time through ZMQ subscription mechanism, maintaining index state synchronization.
  • Tokenizer Management: Supports multi-model tokenizer loading and caching, automatically converting conversation messages to token sequences.

Architecture Components

Component Description
KVIndexer Core management class, coordinating service discovery, index management and HTTP services.
IndexTree Prefix tree implementation, supporting node addition/deletion and token matching depth query.
TokenizerManager Tokenizer loading and cache management.
ZMQManager ZMQ subscription management, handling cache change messages.
K8sServiceDiscovery Kubernetes service discovery, obtaining vLLM Pod list.
KVIndexerService FastAPI HTTP service, providing external interfaces.

Local Build

Image Build

Build Commands

  • Build and push to specified OCI repository.

    Using docker
    docker buildx build . -f <path/to/dockerfile> \
        -o type=image,name=<oci/repository>:<tag>,oci-mediatypes=true,rewrite-timestamp=true,push=true \
        --platform=linux/amd64,linux/arm64 \
        --provenance=false \
    
    Using nerdctl
    nerdctl build . -f <path/to/dockerfile> \
        -o type=image,name=<oci/repository>:<tag>,oci-mediatypes=true,rewrite-timestamp=true,push=true \
        --platform=linux/amd64,linux/arm64 \
        --.provenance=false \
    

    Where <path/to/dockerfile> is the Dockerfile path, <oci/repository> is the image address, and <tag> is the image tag.

  • Build and export OCI Layout to local tarball.

    Using docker
    docker buildx build . -f <path/to/dockerfile> \
        -o type=oci,name=<oci/repository>:<tag>,dest=<path/to/oci-layout.tar>,rewrite-timestamp=true \
        --platform=linux/amd64,linux/arm64 \
        --provenance=false \
    
    Using nerdctl
    nerdctl build . -f <path/to/dockerfile> \
        -o type=oci,name=<oci/repository>:<tag>,dest=<path/to/oci-layout.tar>,rewrite-timestamp=true \
        --platform=linux/amd64,linux/arm64 \
        --provenance=false \
    

    Where <path/to/dockerfile> is the Dockerfile path, <oci/repository> is the image address, <tag> is the image tag, and path/to/oci-layout.tar is the tar package path.

  • Build and export image rootfs to local directory.

    Using docker
    docker buildx build . -f <path/to/dockerfile> \
        -o type=local,dest=<path/to/output>,platform-split=true \
        --platform=linux/amd64,linux/arm64 \
        --provenance=false \
    
    Using nerdctl
    nerdctl build . -f <path/to/dockerfile> \
        -o type=local,dest=<path/to/output>,platform-split=true \
        --platform=linux/amd64,linux/arm64 \
        --provenance=false \
    

    Where <path/to/dockerfile> is the Dockerfile path and path/to/output is the local directory path.

Helm Chart Build

  • Package Helm Chart.

    helm package <path/to/chart> -u \
        --version=0.0.0-latest \
        --app-version=openFuyao-v25.09
    

    Where <path/to/chart> is the Chart folder path.

  • Push Chart package to specified OCI repository.

    helm push <path/to/chart.tgz> oci://<oci/repository>:<tag>
    

    Where <path/to/chart.tgz> is the Chart package path, <oci/repository> is the Chart package push address, and <tag> is the Chart package tag.

Introduction

提供AI推理场景中的全局KV Cache管理能力

Customize your domain