Asked at
URL Shortener (TinyURL)
Asked from Junior level upFoundations & Storage
Distributed Rate Limiter
Asked from Mid level upAPI Gateway & Security
Distributed Key-Value Store
Asked from Senior level upFoundations & Storage
Distributed Notification Service
Asked from Mid level upMessaging & Queues
Distributed Web Crawler
Asked from Mid level upDistributed Systems
Metrics & Monitoring Platform
Asked from Senior level upObservability & Time-Series
Real-Time Chat App (like WhatsApp or Slack)
Asked from Mid level upReal-Time & WebSockets
Social News Feed (like X/Twitter)
Asked from Mid level upSocial & Feed Systems
Ride-Hailing App (like Uber)
Asked from Senior level upGeospatial & Real-Time
Low-Latency Stock Exchange Matching Engine
Asked from Staff level upFintech & Low Latency
Global Video Streaming Platform (like YouTube or Netflix)
Asked from Senior level upMedia & Streaming
Distributed Hotel & Ticket Reservation System
Asked from Mid level upE-Commerce & Transactions
Shared Document Editor (like Google Docs)
Asked from Staff level upReal-Time & Distributed State
Game Leaderboard
Asked from Junior level upCaching & Data Structures
File Sync Service (Dropbox / Google Drive)
Asked from Mid level upStorage
Payment System
Asked from Senior level upPayments & Transactions
Ad Click Aggregation
Asked from Senior level upStream Processing
AI Support Assistant (RAG)
Asked from Senior level upAI Systems
LLM Inference Platform
Asked from Senior level upAI Systems
Enterprise Semantic Search
Asked from Mid level upAI Systems
AI Code Completion
Asked from Senior level upAI Systems
LLM Gateway
Asked from Senior level upAI Systems
AI Agent That Takes Actions
Asked from Senior level upAI Systems
LLM Evaluation Platform
Asked from Senior level upAI Systems
AI Document Processing Pipeline
Asked from Mid level upAI Systems

Design Enterprise Semantic Search

Asked from Mid level upEmerging topicPart of the AI track: start with AI basicsDomain: AI Systems
Concepts to know first:

Let employees search every company document by meaning, across wikis, drives and tickets, while showing each person only what they are allowed to see.

An analogy

Like a librarian who understands what you mean, not only the words you type. You ask about 'travel refunds' and get the page called 'expense claims for trips'. The librarian also never hands you a locked file.

Where this analogy stops working: A librarian checks your pass at the desk each time. The search system knows only the permissions it last copied from each source, so it must hear about every change quickly.

Where this design ends up. This is version 3 of 3. Part 5 builds it up from version 1 and says why each part was added.
  1. People & sources
    • Employee
    • Wiki, drives, tickets
  2. Ingest
    • Change queue + chunker
  3. Meaning
    • Embedding model
  4. Index
    • Sharded index
  5. Search
    • Search API
    • Reranker

1. Requirements and scope

Functional Requirements
  • Search documents from several sources, such as the wiki, shared drives and tickets, in one box.
  • Match by meaning as well as by exact words, then show the best results with a short snippet.
  • Show each employee only documents they may open in the original source.
  • Reflect a new or edited document within a few minutes.
Non-Functional Requirements & SLAs
  • Results within about 500 ms for 95 of every 100 searches (the p95).
  • A permission change must take effect quickly; a leak is worse than a slow result.
  • Search quality is measured, not guessed.
  • Index updates must not slow down searches.
Key Traffic Assumptions: 10,000 employees, each searching about 20 times a working day. • 20 million documents, split into about 80 million chunks; about 500,000 edits a day. • The busiest hour is about twice the average.

2. Back-of-the-envelope numbers

Writes and reads each second
  • Writes: 6 documents indexed a second (46%)
  • Reads: 7 searches a second (54%)

Balanced: reads and writes are close. Both paths need care, so neither can be slow.

Write Throughput
500,000 edits ÷ 86,400 ≈ 6 documents/s to re-chunk and re-embed
Read Throughput
10,000 × 20 = 200,000 searches a day; over an 8-hour working day ≈ 7/s, about 15/s at peak
Storage Growth
Vectors: 80M chunks × 768 numbers × 4 bytes ≈ 245 GB, or about 61 GB as 1-byte numbers. The keyword index and text add about as much
RAM Cache Footprint
Cache each employee's group list for a minute or less, dropped when a group change arrives. Results are not shared across people, since permissions differ

3. API

GET/v1/search?q={text}&source={wiki|drive|tickets}Results this employee may see: title, snippet, link, source
POST/v1/connectors/{source}/eventsA source reports a created, edited or deleted document, or a permission change
POST/v1/feedback{ queryId, resultId, clicked }

4. Data model and storage

Storage Strategy: A search engine such as OpenSearch holds both a keyword index and a vector index, with each chunk's allowed groups stored beside it. A relational database tracks sources, documents and sync state.
CHUNK(id, doc_id, source, text, embedding, allowed_groups[], updated_at) · DOCUMENT(id, source, title, url, owner, version) · GROUP_MEMBER(group_id, employee_id)

5. The design, in three versions

Version 1: Keyword search over one source

A nightly job copies the wiki into a keyword index. The search box matches the exact words people type.

Search v1: Nightly Keyword Index Version 1 of 3

The picture follows one request through the parts of this version, in order. Under it, switch a part off to see what the request does without it.

One request, step by step

Each numbered arrow is one step. Press "Simulate Request Flow" to follow them one at a time.

EmployeeWikiNightly copy jobKeyword indexSearch API123
  • The order of the steps
  • A request or its reply

The parts: switch one off

1. People & sources

EmployeeTypes a question
WikiCopied by a job

2. Ingest

Nightly copy jobOnce a day

3. Index

Keyword indexExact words

4. Search

Search APIMatches words
Example figures
Time budget
< 500 ms

The steps in words0 of 3 steps shown

  1. Employee to Search APIHTTPS · 20ms

    GET /v1/search?q=travel refunds

  2. Search API to IndexKeyword query · 60ms

    Match the words "travel refunds"

  3. Search API to EmployeeHTTP/200 · 10ms

    Pages containing those words

Why this version
Useful search for one source in a week.
Next bottleneck
Different words for the same idea miss each other, other sources are not covered, and results are a day old.

Write path, read path and failures

Each path follows one request through the final design (version 3), one hop at a time.

Write pathIndex an edited document

  1. Drive
  2. Change queue
  3. Chunker
  4. Embedding model
  5. Index
  1. Drive to Change queue

    An edit or a sharing change in a source sends a change event.

  2. Change queue to Chunker

    A worker reads the document again and cuts it into passages.

  3. Chunker to Embedding model

    Each passage gets a vector.

  4. Embedding model to Index

    The index replaces the document's old passages, along with the people and groups who may see it.

Read pathSearch

  1. Employee
  2. Search API
  3. Index
  4. Reranker
  1. Employee to Search API

    An employee types a question.

  2. Search API to Index

    One query runs a keyword search and a vector search together, limited to documents this employee may open.

  3. Index to Reranker

    The reranker reads the top 50 results with the question and orders the best 10.

  4. Reranker to Employee

    The results appear with links. The permission filter ran inside the query, not after it.

What breaks, and what happens then

  • Someone loses access, but the index has not caught up

    What users see
    For a few minutes, a search could show a document they can no longer open.
    What the design does
    Sharing changes go to the front of the queue, and the Search API checks access to each result before showing it.
  • The embedding model is upgraded

    What users see
    Old and new vectors cannot be compared.
    What the design does
    Build a second index with the new model, test it on the judged queries, then switch.
  • A large source is copied in again from scratch

    What users see
    New edits wait behind it in the queue.
    What the design does
    Live edits use their own queue, ahead of bulk work.
  • The reranker is slow

    What users see
    Searches take longer than the 500 ms goal.
    What the design does
    Give the reranker a time limit. If it runs out, show the results in their first order.

6. Deep dives

Permissions inside the query
Store each chunk's allowed groups in the index and filter inside the search itself. Filtering after retrieval can return too few results, and one bug would show a locked document. When a group changes, only that group's membership updates, not every chunk.
Changing the embedding model
Vectors from two models cannot be compared, so build a second index with the new model in the background. Score both on the judged queries, then switch traffic and delete the old index.

7. Follow-up questions

  • An employee leaves a project. When do its documents stop showing up? (As soon as the group change event arrives, because the search filters by the employee's current groups at query time.)
  • Users say results got worse last week. How do you find out why? (Rerun the judged queries against last week's settings, compare scores per change, and check the click data for the drop.)

What it costs

The index is modest: about 245 GB of vectors. The steady cost is embedding every changed document, about 6 a second. Embed only the parts of a document that changed, and store smaller vectors.

Another way to design it

You can build a separate index for each team or source. Permission checks become simple, because a person searches only the indexes they may see. A search across the whole company then needs many queries.

8. How answers are judged

A passing answer at Mid level. A complete design with numbers: about 7 searches a second, 80 million chunks, about 6 edited documents a second. It explains embeddings and hybrid search, and goes deep on permissions.

How each level is judged
What is judgedJuniorMidSeniorStaff
BreadthHow much of the system does the answer cover?Names the core parts: clients, servers, a database and a cache.Covers the whole main flow, from the request to the stored data and back.Builds a complete design without being led through it.Covers the system, the systems around it and who owns each part.
DepthHow far does it go into the hard parts?Explains what each part does and why it is there.Goes deep on one part, such as the database or the cache.Goes deep on the two or three riskiest parts.Goes deepest where the risk is largest, and explains why the risk is there.
DrivingWho leads the conversation?Follows the interviewer, step by step.Moves forward alone, with an occasional nudge.Leads the conversation from start to finish.Changes the problem when the question asked is not the right one.
Trade-offsAre choices compared and justified?Names more than one option.Says why one option was picked over another.Compares options in detail, with what each one costs.Ties each choice to cost, speed and risk for the business.
Unclear questionsWhat happens when the question is vague?Answers the questions that are asked.Asks questions to make the problem clear.Sets the scope and says what is left out.Questions the assumptions behind the problem itself.
ScopeWhat does it consider beyond the normal path?Covers the normal path, when everything works.Adds what happens when a part fails.Adds growth: what breaks at ten times the load, and the fix.Adds abuse, cost and the daily work of running the system.

Requirements and scope

Strong answer
Before I design, I want to check the scope. Which sources come first, and how fresh must results be? Each employee must see only what they can open in the original source. I will assume edits show within minutes, and that a leak is worse than a missing result.
Weak answer
Everyone in the company works together, so I will let every employee search every document. I can fix permissions later if someone complains.

Shows: Unclear questionsThe difference: Search makes hidden files easy to find, so it would expose salaries, legal and HR files to everyone. Permissions must be part of the first design.

Estimates

Strong answer
10,000 employees searching 20 times a day is 200,000 searches, about 7 a second over working hours. 80 million chunks of 768 numbers at 4 bytes each is about 245 gigabytes of vectors, or about 61 gigabytes stored as 1-byte numbers.
Weak answer
20 million documents at one vector each, 3 kilobytes per vector, is about 60 gigabytes in total.

Shows: DepthThe difference: Each document is split into several chunks, about 80 million in all, and each chunk needs its own vector. That is about four times more.

Core design

Strong answer
Connectors pull each source, split documents into chunks of a few hundred words, and embed each chunk. A search runs keyword and vector search together, filtered to this employee's groups inside the query. The two lists are merged, then a reranker orders the best few.
Weak answer
I would search all chunks by meaning, take the top 10, and then remove any the employee is not allowed to see.

Shows: DepthThe difference: Filtering afterwards can leave few or no results, and a single bug would show a locked document. The filter belongs inside the query.

Deep dive

Strong answer
The hard part is knowing whether a change helps. I would keep a set of real queries with judged good results and score every change to chunking, models or ranking against it. Click data shows problems the judged set misses.
Weak answer
I would try a new embedding model by switching the index to it for everyone, and see whether people complain.

Shows: DepthThe difference: Complaints come late and say little. Vectors from two models also cannot be mixed, so test on judged queries with a second index first.

Failures and trade-offs

Strong answer
If the embedding service is down, searches fall back to keyword results, which still work. If change events stop, a nightly full sync catches up, and an alert fires when the index falls behind. A permission removal is applied before any other update.
Weak answer
If the embedding service is down, the search page shows an error until it comes back.

Shows: Trade-offsThe difference: Keyword search does not need the embedding model, so it can keep answering. A degraded result beats no result for most searches.

We wrote this guide in our own words, informed by public interview guides such as AlgoMaster and Hello Interview. We are not connected to either site. Interviewers differ. The guide and the example answers show the direction each level takes, not a checklist.

10. Check your design with your own AI

Write your design first. Then copy this prompt into the AI chat you already use, and add your design at the end. It asks for a score in each area, one fix for each, and two follow-up questions.

The site sends nothing anywhere. An AI review can be wrong, so check what it says against sections 8 and 9.

See the prompt
You are a system design interviewer. Review my design for the interview problem below.

Problem: Design Enterprise Semantic Search
Let employees search every company document by meaning, across wikis, drives and tickets, while showing each person only what they are allowed to see.

What users must be able to do:
- Search documents from several sources, such as the wiki, shared drives and tickets, in one box.
- Match by meaning as well as by exact words, then show the best results with a short snippet.
- Show each employee only documents they may open in the original source.
- Reflect a new or edited document within a few minutes.

How well it must work:
- Results within about 500 ms for 95 of every 100 searches (the p95).
- A permission change must take effect quickly; a leak is worse than a slow result.
- Search quality is measured, not guessed.
- Index updates must not slow down searches.

Numbers to assume:
- 10,000 employees, each searching about 20 times a working day.
- 20 million documents, split into about 80 million chunks; about 500,000 edits a day.
- The busiest hour is about twice the average.

Judge my design at the Mid level.
A passing answer at this level: A complete design with numbers: about 7 searches a second, 80 million chunks, about 6 edited documents a second. It explains embeddings and hybrid search, and goes deep on permissions.

For each area below, say whether my design is strong, fine or weak. Give one reason and one fix for each:
1. Requirements and scope
2. Estimates
3. Core design
4. Deep dive
5. Failures and trade-offs

Then ask me the two follow-up questions an interviewer would ask next.
Do not write a full model answer for me.

My design:
[Describe your parts, how one request moves through them, and why you chose each one.]