Architect a cross-modal search engine indexing 100M images, 750M video keyframes, and 500M text documents at 15,000 peak QPS with p95 < 200 ms, Recall@100 >= 0.92, and < 30s ingestion freshness.
From patterns to decisions.
Architect a cross-modal search engine indexing 100M images, 750M video keyframes, and 500M text documents at 15,000 peak QPS with p95 < 200 ms, Recall@100 >= 0.92, and < 30s ingestion freshness.
Stage 1: Requirements Framing & Latency Budget Allocation.
The engine must index 100M images, 50M videos (750M keyframes), and 500M text documents with < 30s p95 ingestion freshness. At 15,000 peak QPS (60% text, 30% image, 10% video region), the 200 ms p95 budget allocates 35 ms to query encoding, 30 ms to parallel scatter-gather, 8 ms to RRF fusion, 42 ms to ColPali MaxSim NVMe reranking, 15 ms to temporal collapse, and 10 ms to metadata hydration.
140 ms Nominal Critical Path Within 200 ms p95 Search SLO
1.60 ms Tail Buffer: Keeping nominal stages at 140 ms leaves 60 ms headroom for straggler shards and GC pauses under 1.5x peak load.
2.30s Freshness SLO: Streaming Kafka-to-TensorRT ingestion commits new keyframes into mutable HNSW delta segments within 30 seconds.
Allocating explicit millisecond budgets across encoding, scatter-gather, MaxSim reranking, and temporal collapse protects the 200 ms p95 SLO.
Stage 2: Capacity Math & Memory Tiering (DRAM vs. NVMe).
Uncompressed 1150-D FP32 embeddings for 850M visual items total 3.91 TB. Tier A applies SQ8 (1 byte/dim = 977.5 GB) plus HNSW M=16 graph links (108.8 GB), provisioned at 1.8 TB DRAM (15 x 128 GB nodes) with headroom. Tier B uses PQ64 (54.4 GB in-RAM codebooks + 1.03 TB on 3 TB NVMe), while ColPali SQ2 stores 1024 x 128-D patches for 50M pages in 1.84 TB across an 18 TB NVMe array.
4-Tier Storage Footprint for 850M Visual Vectors & 50M Patch Grids
1.3x DRAM Safety Factor: Provisioning 1.8 TB DRAM for 1.09 TB raw SQ8+HNSW accommodates OS page cache, segment merges, and RF=2.
2.5x NVMe IOPS Headroom: 18 TB NVMe array for 1.84 TB ColPali SQ2 patches absorbs 15,000 QPS concurrent random 36 KB reads.
Tiering SQ8 HNSW in DRAM, PQ64 DiskANN on NVMe, and SQ2 ColPali patches on high-IOPS NVMe avoids multi-terabyte FP32 DRAM costs.
Stage 3: Typed gRPC Contracts & Hybrid Multimodal Payloads.
SearchMultimodalRequest accepts a QueryModality enum (TEXT, IMAGE_BYTES, HYBRID_MULTIMODAL), optional text_query and image_query_bytes, VectorFilter predicates, enable_colpali_rerank, rerank_depth (default 200), and rrf_k_parameter (default 60.0). Responses return CandidateMatch records carrying dense, lexical, and late-interaction scores plus video timestamp_start_sec and timestamp_end_sec bounds.
MultimodalSearchEngine gRPC Contract & Score Provenance
1.Score Provenance: Returning dense_score, lexical_score, and late_interaction_score enables offline NDCG debugging.
2.Temporal Bounding: CandidateMatch returns timestamp_start_sec and timestamp_end_sec so video players seek directly to the matched clip.
Typed protobuf contracts unify text, image, and hybrid search while exposing per-stage scores and video clip timestamps.
Stage 4: Video Keyframe Chunking & TensorRT Batch Inference.
An FFmpeg demuxer extracts YUV420 frames and computes Bhattacharyya HSV histogram deltas (> 0.30) followed by 64-bit pHash Hamming checks (>= 8), reducing 30 fps video to ~0.5 keyframes/sec. A dynamic batch assembler groups 128 keyframes per TensorRT FP16/BF16 batch on SigLIP-So400M and ColPali workers, committing vectors to HNSW, DiskANN, and BM25 within 30s.
30 fps Demux -> pHash Dedupe -> Dynamic Batch TensorRT Inference
1.TensorRT Throughput: FP16/BF16 dynamic batching (B=128) maximizes GPU Tensor Core occupancy while holding p95 ingestion < 30s.
2.Idempotent Asset Writes: Deterministic asset_id + frame_index keys prevent duplicate index entries on worker retries.
Scene-cut filtering, pHash deduplication, and TensorRT dynamic batching convert raw video into indexed vectors in under 30 seconds.
Stage 5: Scatter-Gather Query Routing & Semantic Cache.
Incoming queries first probe a semantic cache for near-duplicate embeddings before fanning out in parallel across Hot HNSW+SQ8 shards, Warm DiskANN+PQ64 shards, and BM25 partitions. Hedged requests mitigate tail-shard stragglers, and the router merges Top-200 lists from each tier via Reciprocal Rank Fusion (k=60) in ~8 ms.
Hedged Scatter-Gather Across Vector & Lexical Shards
1.Tail-Latency Hedging: Issuing a backup read to a replica shard after 18 ms caps straggler impact at 15,000 QPS.
2.Recall@100 >= 0.92: Combining dense visual recall with BM25 keyword recall hits >= 0.92 Recall@100.
Semantic caching, hedged shard reads, and RRF fusion keep first-pass retrieval fast and resilient at 15,000 QPS.
Stage 6: ColPali MaxSim Reranking & 5s Temporal Window Collapse.
For the Top-200 RRF candidates, the reranker issues async NVMe reads totaling 7.2 MB (200 x 36 KB SQ2 patch grids) and computes MaxSim token-to-patch inner products in ~42 ms. Next, a 15 ms post-processor groups keyframes by video_id and collapses hits within a 5-second sliding window, selecting the highest-scoring frame and merging [t_start, t_end] bounds.
7.2 MB Async NVMe MaxSim + 5-Second Video Window Deduplication
1.Result Diversity: Collapsing 5-second windows prevents one video scene from monopolizing all Top-10 result slots.
2.Bounded NVMe Bandwidth: At 7.2 MB/query, 15,000 QPS with 10% ColPali-reranked traffic stays well within NVMe array throughput.
Async NVMe MaxSim reranking and 5-second temporal collapse deliver high-precision clip-level results within 57 ms.
Stage 7: Drift Governance, Backpressure & Graceful Degradation.
Under 1.5x peak QPS (> 22,500 QPS), adaptive load shedding disables Tier B DiskANN fan-out or narrows ColPali rerank_depth from 200 to 50 to keep p99 < 450 ms. Simultaneously, CI/CD blue-green encoder deployments evaluate mean cosine drift on 10,000 golden anchors and automatically abort if Delta > 0.03.
Adaptive Rerank Shedding & <= 0.03 Cosine Drift Canary Gate
1.Graceful Degradation: Trimming rerank_depth from 200 to 50 cuts NVMe patch I/O by 75% during traffic surges.
2.Zero Corrupt Shards: Enforcing Delta <= 0.03 stops misaligned model weights before they poison live HNSW indexes.
Dynamic rerank shedding protects p99 < 450 ms under load spikes while golden-anchor drift gates prevent index corruption.
Practice: Make the trade-off yourself.
Why does Tier A (Hot DRAM) use SQ8 quantization (1 byte/dim) instead of FP32 or PQ64 for 850M 1150-D vectors?