ML System Design — End to End
Design any ML system from scratch. The framework, tradeoffs, capacity estimation, and how to present it in a senior ML engineering interview.
Every ML system design problem has the same eight questions. Answer them in order and you will never miss a critical component.
ML system design interviews — and real ML architecture discussions — feel open-ended and overwhelming. You are handed a problem like "design DoorDash's delivery time prediction system" and expected to produce a coherent architecture in 45 minutes. Without a framework you will either forget something important or spend 30 minutes on model selection when the interviewer cares about serving infrastructure.
The framework below is not a rigid script — it is a checklist of the questions every ML system must answer. Work through them in order. Each answer constrains the next. The latency requirement determines whether you can use online or batch serving. The scale requirement determines whether you need a feature store. The feedback loop determines how you detect drift. By the time you have answered all eight you have a complete architecture.
An architect designing a building does not start by choosing the colour of the walls. They start with: who lives here, how many people, what activities happen inside, what is the budget, what are the structural constraints of the land. The colour comes last. ML system design is the same — the model choice (colour of the walls) comes after you understand the data availability, latency requirements, and scale constraints. Most candidates start with model selection and never get to the questions that actually determine system feasibility.
In ML system design interviews, an interviewer would rather see you ask the right clarifying questions than immediately jump to "I would use a Transformer." The right questions demonstrate systems thinking. The immediate model answer demonstrates pattern matching.
Design DoorDash's delivery time prediction system — full walkthrough
This is the most commonly asked ML design question in interviews. Delivery time estimation appears at DoorDash, Uber Eats, Gopuff, Instacart, and every quick-commerce startup. Walk through all eight questions.
Design Stripe's real-time fraud detection system
Fraud detection is fundamentally different from delivery time prediction. The class imbalance is extreme (0.1% fraud rate). The cost asymmetry is severe (false negative = fraud loss, false positive = legitimate transaction declined = customer anger + lost revenue). Latency is critical — the prediction must complete before the payment clears. And the adversary is adaptive — fraudsters study and evade every model.
Design Shopify's product recommendation system — two-stage retrieval
Recommendation systems are the third most common ML design question after delivery time and fraud. The key insight almost every candidate misses: you cannot run a complex ranking model over 50 million products. The two-stage architecture — fast retrieval of 100-500 candidates, then expensive ranking of just those candidates — is how every production recommendation system works at scale.
Six recurring tradeoffs — know these and you can handle any ML design question
Real-time prediction at request time. Required when: prediction depends on request context (fraud amount, delivery distance). Latency-sensitive. Higher cost.
Pre-compute predictions for all entities daily. Possible when: context does not change per-request (user recommendations pre-computed by user_id). Lower cost, higher throughput.
High precision (low threshold): fewer false positives. For fraud: fewer declined legitimate transactions. Cost: miss more fraud.
High recall (high threshold): catch more fraud. For fraud: higher false positive rate. Cost: more customer complaints.
Simple model (LightGBM): 1ms inference, interpretable, less accurate. Deployed as single endpoint.
Complex model (deep learning): 100ms+ inference, better accuracy. Requires GPU serving, model quantisation, or batching.
Real-time features: maximum freshness, maximum cost. Requires streaming infrastructure (Kafka, Flink). For fast-changing signals (fraud velocity, driver location).
Batch features: stale but cheap. Daily or hourly batch job. For slowly-changing signals (user purchase history, restaurant prep time baseline).
Global model: simpler, one deployment, data pooling. Worse for underrepresented segments (tier-2 cities with little data).
Per-segment models: better for each segment, higher maintenance. n models to retrain, monitor, and deploy.
Full automation: fast, scalable, no human cost. Risk: wrong automated decision at scale (e.g. fraud model blocks all transactions during a bug).
Human review for high-stakes decisions: slower, expensive, required for regulatory compliance. Fraud above $10K, medical diagnosis, loan decisions.
Time allocation and what interviewers are actually scoring
Inside a real system design interview — and the design review meeting it rehearses
Everything above is the finished framework. What actually happens in the room is messier and more interactive than a checklist suggests — the interviewer interrupts, redirects, and grades you on the questions you ask as much as the architecture you eventually draw. This back-and-forth is not an artificial interview construct. It is a compressed version of the design review meeting that happens before any real ML system ships.
Notice that the interviewer never lets the candidate stay on model architecture for more than a sentence. That redirect is deliberate — it is exactly what a staff engineer does in an actual design review before a system is allowed to move to implementation.
At an actual company this conversation happens as a written design document circulated before code is written, reviewed in a meeting with a senior or staff engineer plus stakeholders from data engineering, and — for anything touching payments or health data — legal and compliance. The reviewer asks the same eight questions in the same order, and the document gets sent back for another pass if data, cold start, or a failure mode was skipped, no matter how elegant the model section reads. Rehearsing the interview version of this conversation is, in a very literal sense, rehearsing the actual job: defending a design against exactly these questions before anyone commits engineering time to building it.
It is rarely knowledge of a fancier model. It is asking about label strategy and failure modes unprompted, before the interviewer has to drag it out of you — the same behaviour a staff engineer expects to see in a design document review, where an author who anticipates the hard questions is trusted with more scope than one who has to be walked through them.
Five things people get wrong about ML system design
Model selection is one of eight equally necessary questions, and the scoring rubric in the previous section weights data and system design far higher than model selection alone. Most real systems fail from a data quality gap, a missing cold-start plan, or no fallback when the model is unavailable — not from choosing the second-best model family. A LightGBM baseline with solid data and monitoring beats a state-of-the-art model with no failure plan every time.
It is about the entire lifecycle end to end: how labels are obtained, how features reach the model consistently at both training time and serving time, what happens when the model is unavailable, and how drift gets detected. The model is one box in a diagram that also contains a feature store, a fallback path, and a monitoring dashboard — and in a well-drawn diagram, the data flow usually takes up more space than the model box itself.
Multiple architectures can satisfy the same constraints — online versus batch serving, one global model versus per-segment models — and reasonable engineers land in different places depending on team size, existing infrastructure, and risk tolerance. What is actually being evaluated is whether the chosen tradeoff is justified given the stated constraints, not whether the answer matches a fixed key.
Reaching for complexity the problem does not need is graded down, not up, in both interviews and real design reviews. It signals that the actual constraint — usually latency, data volume, or an explainability requirement — was never identified. Both interviewers and real staff engineers are more impressed by "I considered a transformer, but the latency budget rules it out, so I would start with gradient boosting" than by simply naming the newest model.
Real ML systems keep hitting the monitoring and failure-modes questions long after the first architecture ships — drift, a new fraud pattern, a data pipeline outage — so the design keeps getting revisited. This is exactly why interviewers spend the last five to ten minutes on "what would you do differently at ten times scale" — a design that only ever gets defended once, at kickoff, was never actually a complete design.
ML system design — 5 questions interviewers actually ask
Resist the urge to start drawing an architecture immediately. Spend the first three to five minutes purely on clarifying questions covering scale, latency, and the business metric, then explicitly state the ML task type and label definition before touching data or model. Say the structure out loud — problem framing, then data, features, model, serving, scale, monitoring, failure modes — so the interviewer can redirect you toward whichever area they care about most. Announcing the structure signals more seniority than any single model choice.
Batch serving pre-computes predictions for every entity on a schedule and looks them up at request time — cheap and simple, but stale, and infeasible when there are too many context combinations to precompute, like a fraud score that depends on the exact transaction amount and merchant at that instant. Online serving computes the prediction at request time using live features, required whenever the prediction depends on information only available at request time, at the cost of a tighter latency budget and supporting infrastructure. Decide by asking whether the prediction depends on real-time context: if yes, online; if the entity list is fixed and small enough to enumerate, batch is dramatically cheaper.
Fall back to a coarser aggregate that does have data — a city or category average instead of entity-specific features, a popularity-based recommendation instead of a personalised one, or a simple rule instead of a learned estimate — and explicitly flag the entity as cold so the fallback is a deliberate choice, not missing data silently treated as zero. As the entity accumulates interactions, blend from the coarse fallback toward the entity-specific model. Mention this proactively — cold start is a near-universal follow-up question if you do not raise it first.
Start with a single global model — it pools data, is simpler to maintain, and avoids duplicating monitoring and retraining work across many models. Split into per-segment models only when there is evidence the global model materially underperforms on a specific segment, that segment has enough data to support its own model, and the business impact justifies the ongoing maintenance of several models instead of one. Segmenting too early is a common overengineering mistake that adds operational burden without adding accuracy.
Treat it as a chance to show you understand where your design's current assumptions break, not a chance to redesign from scratch. Name the first concrete thing that breaks — a feature store lookup pattern fine at hundreds of requests per second becomes a bottleneck at thousands, a single model trained daily may need to become segment-specific once there is enough data per segment, a rule-based fallback that handled rare outages may need real redundancy once outages become frequent enough to matter. This question tests whether your original design had implicit assumptions you can now name.
The MLOps section is complete. Section 12 — Cloud ML Platforms — connects everything to Azure ML, SageMaker, and Vertex AI.
You have completed the full MLOps section across seven modules: ML pipelines and feature stores, experiment tracking, model deployment, monitoring, retraining pipelines, DVC, and ML system design. Section 12 shows how all of this maps onto the managed cloud platforms — Azure ML, AWS SageMaker, and GCP Vertex AI — that most enterprise ML teams use. The concepts are identical; the platforms automate the infrastructure so you can focus on the ML.
Azure Machine Learning Studio, compute clusters, AML Pipelines, AutoML, model registry, and online endpoints.
🎯 Key Takeaways
- ✓Every ML system design problem has the same eight questions answered in order: problem framing → data → features → model → serving → scale → monitoring → failure modes. Answer them in this order — each answer constrains the next. Jumping to model selection first is the most common interview mistake.
- ✓Problem framing before everything: what is the ML task type, what is the business metric (separate from ML metric), how are labels obtained, and what is the latency budget. These four answers determine the entire architecture. Never start designing until you have them.
- ✓Two-stage architecture is the universal pattern for recommendation and search: fast retrieval of 500-1000 candidates (ANN search on pre-computed embeddings), then expensive ranking of only those candidates. Running a neural ranker over 50M products is impossible at real-time serving latency — two-stage is not an optimisation, it is a requirement.
- ✓Capacity estimation is not optional. Give numbers: DoorDash 580 peak RPS → 30 replicas × 20 RPS each at 10ms model latency. Shopify 15M DAU × 3 sessions × 4 requests = 2,083 avg RPS. Fraud detection 1,157 peak TPS at < 10ms model budget → 12 replicas. Interviewers score "thinking in numbers" explicitly.
- ✓Six recurring tradeoffs to master: online vs batch serving (depends on whether real-time features are required), precision vs recall (depends on cost of FN vs FP), model complexity vs latency (start simple, add complexity when plateau), freshness vs cost (compute frequency = signal change rate), global vs per-segment models (add segments when global underperforms >10%), full automation vs human-in-the-loop (automate reversible low-stakes, humans for irreversible high-stakes).
- ✓Always address: cold start problem (new users/items with no history — content-based or popularity fallback), label strategy (how and when ground truth is obtained — delivery time is immediate, fraud is delayed 30 days), and fallback when model is unavailable (rule-based or static fallback — never block the core user action due to ML unavailability).
Discussion
0Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.