Vector Database

Design the storage and query engine of a vector database that indexes billions of embeddings for approximate nearest-neighbor search.

00

Practice checkpoints

The requirements are open as a taste. From the numbers onward, the full guide opens in the app.

  1. 01
    Clarify scope
  2. 02
    Requirements + scale
  3. 03
    API + data modelUnlocks in the app
  4. 04
    Draw architectureUnlocks in the app
  5. 05
    Deep diveUnlocks in the app
  6. 06
    Trade-off decisionUnlocks in the app
01

Requirements that shape the design

Do not only state requirements. Ask for them. Each card pairs the design constraint with a clarification question you can say out loud before drawing the architecture.

Functional requirements

01What is the core query — what goes in, what comes out?

Given a query vector, return the k nearest neighbors by the collection’s distance metric — ids, similarity scores, and stored payloads, with k set per query.

02Can a query say "nearest neighbors WHERE tenant = X"?

Yes: queries combine a metadata filter with vector similarity and the engine still returns k results — filtered search is designed into the index, not bolted on after.

03Is this a build-once index, or do writes land on a live one?

Live: upserts become searchable within seconds without a full rebuild, and a deleted vector stops appearing in results immediately, even if the index frees its memory later.

04Which distance metric — and who picks it?

Cosine, dot product, or L2, fixed per collection at creation — the metric must match how the embedding model was trained, or result quality silently degrades.

05Is accuracy fixed, or a knob the caller can turn?

A knob: each collection declares a recall target, and each query may trade accuracy for speed (efSearch or nprobe) — approximate search is an explicit contract, not an accident.

06One giant index, or many isolated collections?

Many collections, each with its own dimension, metric, index type, and quantization — one tenant’s hot collection cannot starve another’s.

Out of scopeGenerating embeddings — the embedding model belongs to callers; RAG pipelines are consumers of this engine, not part of it · Keyword/BM25 scoring and full hybrid relevance fusion (metadata filters are in scope; text ranking is not) · Cross-region active-active replication and geo-routing

Non-functional requirements

01How fast, at what scale?

p99 query latency around 50 ms at a billion vectors and thousands of QPS — answers come from RAM-resident index structures, never disk scans.

02Approximate — how wrong are we allowed to be?

Recall@10 of at least 0.95, measured against brute-force ground truth on a sampled query set — approximate means measurably wrong sometimes, so recall is a monitored SLO.

03The corpus doubles next year — then what?

Capacity scales horizontally: vectors shard across nodes and queries scatter-gather, so no single node ever holds the whole corpus.

04Does heavy churn quietly rot the index?

Sustained churn does not rot the index: compaction keeps tombstone ratios bounded, and recall decay triggers rebuilds before users notice.

05A node dies — did we just lose vectors?

A node loss never loses vectors: writes are WAL (write-ahead log) durable and raw vectors replicated — the ANN index is a rebuildable acceleration structure, not the source of truth.

Keep asking — the interview is a conversation

Real interviews probe far more than a tidy list. These are the scope questions that separate candidates who interrogate the problem from those who recite it.

  • How many vectors, at what dimensionality — and how fast is the corpus growing?
  • What recall@k does the product actually need — is a missed neighbor invisible to users, or a correctness bug?
  • What is the write pattern — append-mostly, or heavy upserts and deletes that will churn the index?
  • Do queries carry metadata filters, and how selective do they get — 10% of the corpus, or 0.01%?
  • Is the latency budget a per-query p99 for online serving, or throughput for offline batch scoring?
01

Unlock the full playbook for Vector Database

Numbers, architecture diagram, API and data model, deep dives, expected topics, self-check, whiteboard starter, and common mistakes unlock inside the app.

02

Numbers that force architecture decisions

Locked in the app

03

Architecture path

Locked in the app

04

API and data model

Locked in the app

05

Deep dive directions

Locked in the app

+Series

Practice the related series