Skip to content

5. ML System Design Framework ​


Use this 6-step framework for any ML system design question. It provides structure while allowing flexibility for different problem types.

Overview: The 6 Steps ​

StepTimeFocus
1. Problem Clarification5 minRequirements, constraints, success metrics
2. High-Level Architecture5-10 minEnd-to-end system diagram
3. Feature Pipeline5-10 minData sources, feature engineering, feature store
4. Model Training3-5 minAlgorithm choice, training infrastructure
5. Serving & Inference5 minLatency, throughput, deployment strategy
6. Monitoring & Feedback5 minMetrics, drift detection, retraining

Step 1: Problem Clarification (5 min) ​

Goal: Ensure you understand the problem before diving into solutions.

Questions to Ask ​

CategoryExample Questions
BusinessWhat defines success? What's the business metric?
ScaleHow many users? Queries per second? Data volume?
LatencyReal-time or batch? What latency is acceptable?
AccuracyHow much error is tolerable? Cost of mistakes?
ConstraintsPrivacy? Regional compliance? Infrastructure limits?

Example Clarification Dialogue ​

Interviewer: "Design a recommendation system for an e-commerce site."

You: "Before I dive in, I'd like to clarify a few things:

  1. What's our primary metric—revenue, engagement, or user satisfaction?
  2. How many products and users are we dealing with?
  3. What's the latency requirement—real-time or precomputed?
  4. Are there cold start concerns—new users or new products?
  5. Any constraints like fairness across sellers or diversity requirements?"

What You Should Know After Step 1 ​

  • Primary success metric
  • Scale (users, items, QPS)
  • Latency requirements
  • Key constraints
  • Scope boundaries

Step 2: High-Level Architecture (5-10 min) ​

Goal: Draw the end-to-end system before diving into components.

Standard ML System Architecture ​

┌─────────────────────────────────────────────────────────────────────┐
│                         DATA LAYER                                  │
│                                                                     │
│   Batch Data ──────┐    Stream Data ──────┐    External APIs ───┐   │
│   (Data Lake)      │    (Kafka/PubSub)    │                     │   │
└────────────────────┼──────────────────────┼─────────────────────┼───┘
                     │                      │                     │
                     ▼                      ▼                     ▼
┌─────────────────────────────────────────────────────────────────────┐
│                       FEATURE LAYER                                 │
│   ┌─────────────────────────────────────────────────────────────┐   │
│   │                    FEATURE STORE                            │   │
│   │    Offline Store (training)    │    Online Store (serving)  │   │
│   └─────────────────────────────────────────────────────────────┘   │
└──────────────────────────────┬──────────────────────────────────────┘
                               │
         ┌─────────────────────┴─────────────────────┐
         │                                           │
         ▼                                           ▼
┌─────────────────────────────────┐    ┌─────────────────────────────┐
│       TRAINING LAYER            │    │       SERVING LAYER         │
│                                 │    │                             │
│  Training Pipeline              │    │  Model Server               │
│  ├── Data validation            │    │  ├── Load balancer          │
│  ├── Feature transform          │    │  ├── Inference workers      │
│  ├── Model training             │    │  ├── Prediction cache       │
│  └── Model registry             │    │  └── Fallback logic         │
│  └── Evaluation                 │    │                             │
└─────────────────────────────────┘    └─────────────────────────────┘
                                                    │
                                                    ▼
                               ┌─────────────────────────────────────┐
                               │       MONITORING LAYER              │
                               │                                     │
                               │  Metrics │ Alerts │ Drift Detection │
                               │            │                        │
                               │            ▼                        │
                               │     Retraining Trigger              │
                               └─────────────────────────────────────┘

Tips for Drawing ​

  • Start with user request, end with response
  • Show data flow with arrows
  • Identify offline (training) vs online (serving) paths
  • Highlight where you'll dive deeper
  • Keep it clean—details come later

Step 3: Feature Pipeline (5-10 min) ​

Goal: Define what data you need and how to transform it.

Feature Categories ​

CategoryExamplesCompute TimeStorage
StaticUser demographics, item metadataBatchCache
DynamicRecent clicks, session historyReal-timeOnline store
Aggregate7-day average, rolling countsBatchFeature store
ContextualTime of day, device, locationReal-timeCompute at request
CrossUser-item similarityVariesDepends on freshness

Feature Store Design Principles ​

  1. Single source of truth for feature definitions
  2. Point-in-time correctness for training
  3. Low latency for online serving
  4. Versioning for reproducibility
  5. Monitoring for data quality

Critical: Training-Serving Skew ​

Most ML production failures come from training-serving skew.

CauseProblemSolution
Different code pathsFeatures differShared transformation code
Time leakageTraining uses future dataPoint-in-time joins
Missing featuresUnavailable at servingGraceful defaults
Different defaultsNaN handled differentlyCentralized imputation

Step 4: Model Training (3-5 min) ​

Goal: Justify your algorithm choice and training approach.

Algorithm Selection ​

Data TypeSmall DataLarge Data
TabularLogistic Regression, XGBoostXGBoost, Neural Nets
TextTF-IDF + ClassifierBERT, Fine-tuned LLMs
ImagesPre-trained CNNsCustom CNN/ViT
SequencesRNNs, TraditionalTransformers

Trade-off Discussion Template ​

"I'm considering [Option A] vs [Option B]:

Option A: [Pros] / [Cons] Option B: [Pros] / [Cons]

Given [constraint], I'd recommend [choice] because [reason]."

Evaluation Strategy ​

Training Data → K-Fold CV → Offline Metrics
                                ↓
                        Holdout Test Set
                                ↓
                         A/B Test (Online)
                                ↓
                        Long-term Metrics

Step 5: Serving & Inference (5 min) ​

Goal: Design for production requirements.

Latency Budget Example ​

Total budget: 100ms

Feature fetch:        20ms  ████
Feature transform:    10ms  ██
Model inference:      50ms  ██████████
Post-processing:      10ms  ██
Network overhead:     10ms  ██
                      ─────
Total:               100ms

Optimization Techniques ​

TechniqueSpeedupTrade-off
Distillation2-10xSlight accuracy loss
Quantization (INT8)2-4xMinimal accuracy loss
Pruning2-5xDepends on sparsity
Caching10-100xStaleness
BatchingBetter throughputHigher latency

Deployment Strategy ​

Current Model ────────────────────────────► Production Traffic
                                               │
New Model ─► Shadow Test ─► Canary (1%) ─► Gradual Rollout
                │               │
                ▼               ▼
         Compare metrics  Compare metrics

Fallback Strategies ​

ScenarioFallback
Model timeoutReturn cached prediction
Model errorUse rule-based default
Feature missingUse default value
High loadDegrade to simpler model

Step 6: Monitoring & Feedback (5 min) ​

This step is often missed by junior candidates—always cover it!

What to Monitor ​

CategoryMetricsAlert Threshold
PerformanceAccuracy, precision, recallDrop >5%
LatencyP50, P95, P99P95 >SLA
ThroughputQPS, error rateError >1%
DataInput distribution, null ratesDrift detected
BusinessCTR, conversion, revenueDrop >3%

Drift Detection ​

Drift TypeDetection Method
CovariateCompare input distributions (KL divergence)
ConceptMonitor prediction accuracy over time
LabelCompare label distributions

Retraining Triggers ​

TriggerWhen to Use
ScheduledRetrain weekly/monthly
Performance-basedWhen metrics drop below threshold
Drift-basedWhen distribution shift detected
ManualAd-hoc for specific issues

Feedback Loop ​

User Interactions → Label Collection → Data Warehouse
                                            ↓
                                    Training Pipeline
                                            ↓
                                       New Model
                                            ↓
                                        A/B Test
                                            ↓
                                    Deploy if better

Time Management Summary ​

StepMinutesKey Output
Clarify5Requirements confirmed
Architecture5-10System diagram
Features5-10Feature list + store design
Training3-5Algorithm + trade-offs
Serving5Latency + deployment
Monitoring5Metrics + retraining
Buffer5Follow-ups
Total~45 min

Quick Checklist ​

Before finishing, verify you've covered:

  • Clarified business metric and success criteria
  • Defined scale: users, QPS, data volume
  • Drew high-level architecture diagram
  • Discussed feature engineering and training-serving parity
  • Explained model choice with trade-offs
  • Covered serving: latency, caching, fallbacks
  • Addressed monitoring and drift detection
  • Discussed retraining triggers and feedback loops

Common Mistakes to Avoid ​

MistakeWhy It's BadWhat to Do Instead
Jumping to modelMisses requirementsStart with clarification
Ignoring scaleSolution won't workAsk about QPS, data size
No monitoringIncomplete designAlways cover observability
Single solutionShows narrow thinkingDiscuss alternatives
No trade-offsSeems juniorCompare options explicitly
Forgetting fallbacksBrittle systemDesign for failure