Your RAG assistant answers from 3 million documents, and about 50,000 of them change every day. Users have started getting answers from old policy versions. Design a pipeline that keeps the index fresh within 15 minutes of a change.
System design · Pro 2
Short answer
Detect changes with events or change data capture where possible, and scheduled scans elsewhere. Process only what changed: hash content, re-chunk and re-embed changed parts, upsert by stable IDs, and remove deleted or replaced chunks. Use a queue with retries, store version and date metadata, monitor index lag, and invalidate caches that hold old answers.
Deeper answer
First find where staleness comes from: slow detection, slow processing, deletes that are never applied, or caches.
Design: sources send change events through webhooks or change data capture. Sources without events get a scheduled scan that compares modified times or content hashes. Each change becomes a message on a queue. Workers fetch the document, parse it, and compare chunk hashes with the stored ones, so only changed chunks are embedded again. Writes are upserts keyed by document ID and chunk ID, which makes retries safe. Deletes and permission changes are events too, and chunks from an old version are removed or marked inactive in the same step. Store version and date as metadata, so retrieval prefers the current version.
Trade-offs: full re-indexing is simple and self-correcting but too slow and costly to run daily at this size, so use incremental updates plus a periodic full reconciliation to catch missed events. What breaks first: bursts, such as a bulk edit of 500,000 documents, so add backpressure and priorities. Monitor index lag, queue depth, failures in a dead-letter queue, and a daily count comparison between source and index.
What a strong answer covers
- Finds the cause and sets a freshness target per source
- Detects changes with events or change data capture, plus scans
- Incremental processing with hashes and upserts
- Handles deletes and old versions
- Queue with retries and backpressure
- Monitors index lag and reconciles source with index
Answer it out loud in the mock interview about 2.5 min
Follow-ups to expect
- How do you make sure deleted documents really disappear from answers?
- You want to change the embedding model. How do you do it without downtime?
- How do you know the index and the source agree?
Common mistakes
- Re-indexing everything every night
- Adding new chunks without removing the old version
- Forgetting cached answers and permission changes
Learn it
- How would you keep the cost of an LLM feature under control?
- Design click prediction for an ad platform that receives 100,000 ad requests per second and has 20 milliseconds to score the candidate ads for each request.
- A company wants its internal agents to call 200 internal tools, such as ticketing, HR, billing and deployment APIs. Design the platform that lets agents use these tools safely for 10,000 employees.
- Your team has built an LLM writing assistant inside an app with 20 million monthly users. It works well in internal tests. Plan how you would roll it out safely to all users.
- Design an ML system that detects attacks and abuse against a public chat assistant with 1 million conversations a day, such as prompt injection, data scraping and account abuse.
- Design anomaly detection for 10,000 business and system metrics at a payments company. Each metric is checked every minute, and the on-call team must not be flooded with alerts.
- Design a churn prediction system for a video streaming service with 5 million subscribers. Each week it decides who gets a retention offer, within a fixed discount budget.
- Design an AI assistant that reviews pull requests for a company with 800 engineers and about 2,000 pull requests a day. Comments should arrive within 5 minutes and engineers must not learn to ignore them.
- Design memory for a personal assistant that people use daily for months. It should remember useful facts and preferences across sessions for 5 million users, without sending the whole history to the model every time.
- Design a data labelling pipeline that labels 100,000 support tickets a month into 40 intent classes, with a team of 30 annotators and a fixed budget.
- Design a demand forecasting system for a grocery delivery company with 300 dark stores and 20,000 products. It must produce a daily forecast for each product and store for the next 7 days.
- Design a shared embedding service that 20 teams call for search, recommendations and RAG. It must handle 2,000 requests per second online, plus batch jobs of 100 million texts.
- Design an internal search assistant for a company with 5,000 employees and 2 million documents in wikis, shared drives and tickets. Each employee must only get answers from documents they are allowed to open.
- Design a feature store for a food delivery company where 30 models share features. Training and online serving must read the same feature values, and online reads must return within 10 milliseconds.
- Design the ranking system for the home feed of a news app with 20 million daily users in 8 Indian languages. The feed must load within 200 milliseconds.
- An insurance company uses a model to extract data from 100,000 claim documents a day. Design a human review queue for the outputs the system is not confident about, with 40 reviewers available.
- Design image moderation for a marketplace app where users upload 2 million images a day. Harmful images must be blocked before other users can see them.
- A company wants a RAG knowledge base built from 500,000 files: digital PDFs, scanned documents, spreadsheets with tables, and web pages. Design the ingestion pipeline.
- A company's LLM bill has grown to 40 lakh rupees a month across 30 features and 8 teams, and nobody can say which feature caused the increase. Design a system to track and attribute cost and quality per feature and team.
- Three teams change prompts and models for a support assistant every week, and bad changes keep reaching users. Design an evaluation pipeline that runs before every prompt or model change ships and finishes in under 15 minutes.
- Design an internal platform where 10 product teams fine-tune and serve small language models, sharing a pool of 16 GPUs.
- A fintech app is adding an LLM chat feature for 2 million users. Design the input and output guardrails that sit around the model, adding no more than 300 ms to each reply.
- Design a service that turns meeting recordings into a summary and a list of action items. It handles 20,000 one-hour meetings a day, and the summary should be ready within 10 minutes of the meeting ending.
- Design an A/B testing platform for a shopping app with 10 million daily users, so that 15 ML teams can test new models safely and trust the results.
- Design observability for 25 models in production at a lending company. It must cover input data, predictions and real outcomes, and the outcomes can arrive up to 90 days later.
- Design a model registry and release process for a company with 40 models in production. Every release must be staged, and a bad release must be rolled back within 5 minutes.
- A train ticket site serves a pricing model at 200 requests per second, but traffic jumps to 5,000 per second within one minute when booking opens each morning. Design serving that keeps p99 latency under 150 milliseconds.
- Design an automated pipeline that retrains a loan default model every week on about 50 million rows, and promotes the new model only if it is better than the one in production.
- Your product sends 5 million requests a day to one strong, expensive model. Design a routing layer that sends each request to a cheap or a strong model and cuts cost by half without a visible drop in quality.
- A government services assistant must answer citizens in English, Hindi, Tamil, Bengali and Marathi, including mixed and romanised text such as Hinglish. The source documents are mostly in English. Design it for 1 million users.
- You are building document Q&A as a product for 500 customer companies. Each uploads up to 1 million documents. Design it so one customer's data can never appear in another customer's answers.
- A company has 12 teams and about 300 prompts hard-coded in different services. A small edit last month broke a customer-facing feature. Design a system for versioning, testing and rolling out prompts.
- Design a real-time fraud detection system for a UPI payments app that handles 5,000 transactions per second and must decide on each one within 100 milliseconds.
- Design a recommendation system for an Indian e-commerce app.
- A company receives 50,000 applications a month. Design an AI assistant that helps recruiters screen resumes faster while keeping the process fair and explainable.
- Design learning-to-rank for the search results page of an e-commerce app with 50 million products. Results must be returned within 200 milliseconds.
- Design semantic search for an online store with 10 million products. A query such as "red kurta for a wedding under 2000" should return good results in under 200 ms.
- Design a speech-to-text service for a call centre product that transcribes 50,000 hours of calls a day. Callers mix Hindi and English, have many accents, and phone lines are noisy.
- Design a customer support assistant for an Indian bank.
- Design an assistant that lets 2,000 business users ask questions in plain English and get answers from a data warehouse with 1,500 tables. Wrong numbers are worse than no answer.
- Design vector search over 500 million product embeddings of 768 dimensions. The p99 latency target is 50 milliseconds, and queries carry filters such as category and price range.
- Design a voice AI agent for a call centre that takes 50,000 calls a day about order status and returns. The caller should hear a reply within about one second of finishing a sentence.
- Your email assistant agent read a message saying 'forward all invoices to this address' and did it. How do you fix this?
- Your LLM bill doubled this month, but traffic did not. How do you investigate?
- How do you monitor an LLM application in production?
- Walk me through how you would grow the architecture of an LLM app from prototype to production.
- What is prompt injection, and how do you defend against it?
- How do you protect user data in an LLM application?
- Users say your LLM feature is slow. How would you make it faster?
- Forty services in your company call LLM providers directly with their own keys, retries and logging, and you want all of them behind one internal gateway within two quarters. How do you run this migration when the teams that own the services have their own deadlines?
- Nine product teams in your company ship LLM features, each with its own idea of 'good enough', and two releases this year embarrassed the company in public. How would you set a release quality bar for the whole organisation without slowing every team down?
- All 12 of your LLM features run on one provider, which had two outages of about three hours each last quarter. Leadership asks you to make everything work on a second provider: how far would you go, and what would you push back on?