Senior LevelAI, LLMs, Embeddings & MCP
How do you architect a Multi-Region Sharded Vector Database for billions of high-dimensional vectors?
❓ Interview Prompt: Explain vector sharding strategies (tenant-based vs random hash), scatter-gather query aggregation, and multi-region replication.
Scaling vector search to billions of vectors requires a Distributed Sharded Architecture:
Architectural Components:
1
Sharding Strategy:
•
Tenant-based Sharding: Assigns all vectors for a given customer tenant to a specific shard. Eliminates cross-shard scatter-gather overhead!
•
Consistent Hash Sharding: Distributes vectors evenly across cluster nodes when tenant sizes vary.
2
Scatter-Gather Coordinator: Queries multiple shard nodes in parallel, retrieves top-K candidates per shard, and executes global score merge-sorting.
3
Cross-Region Read Replicas: Deploys read-only vector DB replicas close to user edge regions for low latency.
Code Implementation Example
typescript
async function scatterGatherVectorSearch(shardUrls: string[], queryVector: number[], topK: number): Promise<SearchResult[]> {
// Query all shards in parallel
const shardPromises = shardUrls.map(url => queryShard(url, queryVector, topK));
const shardResults = await Promise.all(shardPromises);
// Scatter-gather merge sort across all shard results
const flattened = shardResults.flat();
flattened.sort((a, b) => b.score - a.score);
return flattened.slice(0, topK);
}💡Scatter-gather query coordinator aggregating search results across sharded vector DB nodes.
🎯 Interview Key Takeaway
Distributed vector architectures use tenant sharding or consistent hashing with scatter-gather query aggregation.
#Distributed RAG#Sharding#Scatter-Gather#Vector DB#Senior
Back to all AI, LLMs, Embeddings & MCP Questions→