When designing a multi-tenant semantic cache, enforce tenant pre-filtering, entity/negation guards, and fail-open timeouts under 15 ms.
TL;DR30-second simplified summary▾
100M 384-d SQ8 vectors fit in 110.7 GB DRAM (RF=2) with 400 GB Zstd RocksDB on NVMe. Async Kafka write-back keeps streaming TTFT unblocked.
R & E · Requirements, Scale Targets & 100M Entry Sizing.
Targets: 5,000 RPS sustained, 15,000 RPS peak, >25% combined hit ratio, <15 ms p99 evaluation overhead, 100M active entries.
Sizing 100M 384-d SQ8 vectors = 38.4 GB + 14.4 GB HNSW edges (M=16) + 2.56 GB L1 Radix = 55.36 GB × 2 (RF=2) = 110.7 GB DRAM across 8 shards. Zstd-compressed payloads (2 KB avg) = 400 GB NVMe.
FP32 Unsharded vs. SQ8 Sharded DRAM + NVMe RocksDB
- 153.6 GB raw vectors alone
- 400+ GB uncompressed JSON in RAM
- High GC pauses
- 110.7 GB total DRAM (RF=2)
- 400 GB Zstd NVMe payloads
- <15 ms p99 evaluation
S & H · Storage Entities & 5-Tier Decoupled Architecture.
Edge Gateway normalizes prompts and derives tenant_hash = HMAC-SHA256(master_key, tenant_id). L1 Radix Trie checks exact matches and emits GPU KV-cache pod affinity hints.
L2 queries sharded SQ8 HNSW with a Roaring Bitmap tenant pre-filter, then fetches the Zstd payload from NVMe RocksDB.
End-to-End Semantic & Prompt Caching Topology
A & D · RPC Contracts, Cosine Calibration & Slot Guard.
EvaluateCache accepts (tenant_id, model_id, model_epoch, system_prompt_hash, user_prompt, max_cosine_dist, deadline_ms) and returns hit_tier + cached_payload + kv_prefix_affinity.
Cosine distance calibration divides space into Safe (d < 0.08), Gray (0.08 <= d < 0.14), and Reject (d >= 0.14). An Entity/Negation Slot Guard enforces exact parity on numbers, dates, and negations.
Sub-15ms Evaluation & Fail-Open Origin Fallback
E · Technology Trade-Offs, Dynamic TTL & Epoch Invalidation.
HNSW SQ8 delivers 96.5% Recall@10 in 5.5 ms p99; DiskANN takes 18–25 ms on NVMe (violating SLA) and IVF-PQ distorts cosine distances near tau = 0.08.
Volatility-aware TTL assigns 7d to static docs, 1h to RAG knowledge, and 0s bypass to live data. Bumping model_epoch invalidates stale entries in O(1) without cluster-wide flushes.
L2 Vector Index Engine Trade-Offs (100M 384-d)
D · Failure Modes, Circuit Breakers, Assumptions & Glossary.
Three circuit breakers govern safety: Latency Breaker (>12 ms p99 opens L2 bypass), Drift Breaker (5% shadow LLM Judge drift >1.5% tightens tau from 0.08 to 0.05), and Queue Shedding (worker depth >64).
Assumptions & Limitations: Assumes low-temperature (T <= 0.3) workloads and canonicalizable prompts; high-entropy creative generation or strict real-time feeds must set bypass_cache = true.
Fail-Open Cache Resilience State Machine
A deployment upgrades Llama-3.3-70B weights from v4.1 to v4.2 during peak 15,000 RPS traffic. How do you invalidate stale cached responses without crashing the GPU cluster?
Practice: Make the trade-off yourself.
Why does the design use Roaring Bitmap pre-filtering in HNSW instead of post-filtering top-K results by tenant_id?